Parent

Class/Module Index [+]

Quicksearch

HTML5::EncodingBytes

String-like object with an assosiated position and various extra methods If the position is ever greater than the string length then an exception is raised

Attributes

position[RW]

Public Class Methods

new(value) click to toggle source
# File lib/feed_tools/vendor/html5/lib/html5/inputstream.rb, line 351
def initialize(value)
  super(value)
  @position = -1
end

Public Instance Methods

current_byte() click to toggle source
# File lib/feed_tools/vendor/html5/lib/html5/inputstream.rb, line 364
def current_byte
  raise EOF if @position >= length
  return self[@position].chr
end
each() click to toggle source
# File lib/feed_tools/vendor/html5/lib/html5/inputstream.rb, line 356
def each
  while @position < length
    @position += 1
    yield self[@position]
  end
rescue EOF
end
find_next(byte_list) click to toggle source

Move the pointer so it points to the next byte in a set of possible bytes

# File lib/feed_tools/vendor/html5/lib/html5/inputstream.rb, line 401
def find_next(byte_list)
  until byte_list.include?(current_byte)
    @position += 1
  end
end
jump_to(bytes) click to toggle source

Look for the next sequence of bytes matching a given sequence. If a match is found advance the position to the last byte of the match

# File lib/feed_tools/vendor/html5/lib/html5/inputstream.rb, line 389
def jump_to(bytes)
  new_position = self[position .. -1].index(bytes)
  if new_position
    @position += (new_position + bytes.length-1)
    return true
  else
    raise EOF
  end
end
match_bytes(bytes, lower=false) click to toggle source

Look for a sequence of bytes at the start of a string. If the bytes are found return true and advance the position to the byte after the match. Otherwise return false and leave the position alone

# File lib/feed_tools/vendor/html5/lib/html5/inputstream.rb, line 379
def match_bytes(bytes, lower=false)
  data = self[position ... position+bytes.length]
  data.downcase! if lower
  rv = (data == bytes)
  @position += bytes.length if rv == true
  return rv
end
skip(chars=SPACE_CHARACTERS) click to toggle source

Skip past a list of characters

# File lib/feed_tools/vendor/html5/lib/html5/inputstream.rb, line 370
def skip(chars=SPACE_CHARACTERS)
  while chars.include?(current_byte)
    @position += 1
  end
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.