Class: Element
- Inherits:
-
Object
- Object
- Element
- Defined in:
- lib/parsers/element.rb
Instance Method Summary collapse
- #<<(token) ⇒ Object
-
#initialize ⇒ Element
constructor
A new instance of Element.
Constructor Details
#initialize ⇒ Element
Returns a new instance of Element.
2 3 4 5 6 |
# File 'lib/parsers/element.rb', line 2 def initialize @tokens = [] @attributes = {} @children = [] end |
Instance Method Details
#<<(token) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/parsers/element.rb', line 8 def <<(token) if token.is_a? Array if token.first == :ID @attributes['id'] = token.last elsif token.first == :CLASS @attributes['class'] = token.last end end @tokens << token end |