Parent

Methods

Class/Module Index [+]

Quicksearch

HTML5::ContentAttrParser

Public Class Methods

new(data) click to toggle source
# File lib/feed_tools/vendor/html5/lib/html5/inputstream.rb, line 597
def initialize(data)
  @data = data
end

Public Instance Methods

parse() click to toggle source
# File lib/feed_tools/vendor/html5/lib/html5/inputstream.rb, line 601
def parse
  begin
    #Skip to the first ";"
    @data.position = 0
    @data.jump_to(';')
    @data.position += 1
    @data.skip
    #Check if the attr name is charset 
    #otherwise return
    @data.jump_to('charset')
    @data.position += 1
    @data.skip
    unless @data.current_byte == '='
      #If there is no = sign keep looking for attrs
      return nil
    end
    @data.position += 1
    @data.skip
    #Look for an encoding between matching quote marks
    if ['"', "'"].include?(@data.current_byte)
      quote_mark = @data.current_byte
      @data.position += 1
      old_position = @data.position
      @data.jump_to(quote_mark)
      return @data[old_position ... @data.position]
    else
      #Unquoted value
      old_position = @data.position
      begin
        @data.find_next(SPACE_CHARACTERS)
        return @data[old_position ... @data.position]
      rescue EOF
        #Return the whole remaining value
        return @data[old_position .. -1]
      end
    end
  rescue EOF
    return nil
  end
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.