Class: TokenizerTestParser
- Inherits:
-
Object
- Object
- TokenizerTestParser
- Defined in:
- lib/feed_tools/vendor/html5/tests/tokenizer_test_parser.rb
Instance Method Summary collapse
-
#initialize(tokenizer) ⇒ TokenizerTestParser
constructor
A new instance of TokenizerTestParser.
- #parse ⇒ Object
- #process_eof(token) ⇒ Object
- #processCharacters(token) ⇒ Object
- #processComment(token) ⇒ Object
- #processDoctype(token) ⇒ Object
- #processEmptyTag(token) ⇒ Object
- #processEndTag(token) ⇒ Object
- #processParseError(token) ⇒ Object
- #processSpaceCharacters ⇒ Object
- #processStartTag(token) ⇒ Object
Constructor Details
#initialize(tokenizer) ⇒ TokenizerTestParser
Returns a new instance of TokenizerTestParser.
4 5 6 |
# File 'lib/feed_tools/vendor/html5/tests/tokenizer_test_parser.rb', line 4 def initialize(tokenizer) @tokenizer = tokenizer end |
Instance Method Details
#parse ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/feed_tools/vendor/html5/tests/tokenizer_test_parser.rb', line 8 def parse @outputTokens = [] debug = nil for token in @tokenizer debug = token.inspect if token[:type] == :ParseError send(('process' + token[:type].to_s), token) end return @outputTokens end |
#process_eof(token) ⇒ Object
57 58 |
# File 'lib/feed_tools/vendor/html5/tests/tokenizer_test_parser.rb', line 57 def process_eof(token) end |
#processCharacters(token) ⇒ Object
47 48 49 |
# File 'lib/feed_tools/vendor/html5/tests/tokenizer_test_parser.rb', line 47 def processCharacters(token) @outputTokens.push(["Character", token[:data]]) end |
#processComment(token) ⇒ Object
43 44 45 |
# File 'lib/feed_tools/vendor/html5/tests/tokenizer_test_parser.rb', line 43 def processComment(token) @outputTokens.push(["Comment", token[:data]]) end |
#processDoctype(token) ⇒ Object
20 21 22 23 |
# File 'lib/feed_tools/vendor/html5/tests/tokenizer_test_parser.rb', line 20 def processDoctype(token) @outputTokens.push(["DOCTYPE", token[:name], token[:publicId], token[:systemId], token[:correct]]) end |
#processEmptyTag(token) ⇒ Object
29 30 31 32 33 34 |
# File 'lib/feed_tools/vendor/html5/tests/tokenizer_test_parser.rb', line 29 def processEmptyTag(token) if not HTML5::VOID_ELEMENTS.include? token[:name] @outputTokens.push("ParseError") end @outputTokens.push(["StartTag", token[:name], token[:data]]) end |
#processEndTag(token) ⇒ Object
36 37 38 39 40 41 |
# File 'lib/feed_tools/vendor/html5/tests/tokenizer_test_parser.rb', line 36 def processEndTag(token) if token[:data].length > 0 self.processParseError(token) end @outputTokens.push(["EndTag", token[:name]]) end |
#processParseError(token) ⇒ Object
60 61 62 |
# File 'lib/feed_tools/vendor/html5/tests/tokenizer_test_parser.rb', line 60 def processParseError(token) @outputTokens.push("ParseError") end |
#processSpaceCharacters ⇒ Object
51 52 53 |
# File 'lib/feed_tools/vendor/html5/tests/tokenizer_test_parser.rb', line 51 def processCharacters(token) @outputTokens.push(["Character", token[:data]]) end |
#processStartTag(token) ⇒ Object
25 26 27 |
# File 'lib/feed_tools/vendor/html5/tests/tokenizer_test_parser.rb', line 25 def processStartTag(token) @outputTokens.push(["StartTag", token[:name], token[:data]]) end |