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
# 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
# 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
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
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
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
Generated with the Darkfish Rdoc Generator 2.