Class: Element

Inherits:
Object
  • Object
show all
Defined in:
lib/parsers/element.rb

Direct Known Subclasses

Circle, Ellipse, Line, Path, Rect, RoundRect, SassEl, Svg, Text

Instance Method Summary collapse

Constructor Details

#initializeElement

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