Class: JsonWalker

Inherits:
HTML5::TreeWalkers::Base show all
Defined in:
lib/feed_tools/vendor/html5/tests/test_serializer.rb

Instance Method Summary collapse

Methods inherited from HTML5::TreeWalkers::Base

#initialize, #to_ary

Methods included from HTML5::TreeWalkers::TokenConstructor

#_, #comment, #doctype, #empty_tag, #end_tag, #error, #normalize_attrs, #start_tag, #text, #unknown

Constructor Details

This class inherits a constructor from HTML5::TreeWalkers::Base

Instance Method Details

#eachObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/feed_tools/vendor/html5/tests/test_serializer.rb', line 11

def each
  @tree.each do |token|
    case token[0]
    when 'StartTag'
      yield start_tag(token[1], token[2])
    when 'EndTag'
      yield end_tag(token[1])
    when 'EmptyTag'
      yield empty_tag(token[1], token[2])
    when 'Comment'
      yield comment(token[1])
    when 'Characters', 'SpaceCharacters'
      text(token[1]) {|textToken| yield textToken}
    when 'Doctype'
      yield doctype(token[1], token[2], token[3])
    else
      raise "Unknown token type: " + token[0]
    end
  end
end