Method: HTML5::HTMLInputStream#chars_until
- Defined in:
- lib/html5/inputstream.rb
#chars_until(characters, opposite = false) ⇒ Object
Returns a string of characters from the stream up to but not including any character in characters or EOF. characters can be any container that supports the in method being called on it.
390 391 392 393 394 395 396 397 398 399 400 401 402 403 |
# File 'lib/html5/inputstream.rb', line 390 def chars_until(characters, opposite=false) char_stack = [char] while char_stack.last != :EOF break unless (characters.include?(char_stack.last)) == opposite char_stack.push(char) end # Put the character stopped on back to the front of the queue # from where it came. c = char_stack.pop @queue.insert(0, c) unless c == :EOF return char_stack.join('') end |