Class: DMark::Parser::ElementNode

Inherits:
Object
  • Object
show all
Defined in:
lib/d-mark/parser.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, attributes, children) ⇒ ElementNode

Returns a new instance of ElementNode.



21
22
23
24
25
# File 'lib/d-mark/parser.rb', line 21

def initialize(name, attributes, children)
  @name = name
  @attributes = attributes
  @children = children
end

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



18
19
20
# File 'lib/d-mark/parser.rb', line 18

def attributes
  @attributes
end

#childrenObject (readonly)

Returns the value of attribute children.



19
20
21
# File 'lib/d-mark/parser.rb', line 19

def children
  @children
end

#nameObject (readonly)

Returns the value of attribute name.



17
18
19
# File 'lib/d-mark/parser.rb', line 17

def name
  @name
end

Instance Method Details

#==(other) ⇒ Object



39
40
41
42
43
44
45
46
47
48
# File 'lib/d-mark/parser.rb', line 39

def ==(other)
  case other
  when ElementNode
    @name == other.name &&
      @children == other.children &&
      @attributes == other.attributes
  else
    false
  end
end

#inspectObject



27
28
29
30
31
32
33
34
35
36
37
# File 'lib/d-mark/parser.rb', line 27

def inspect
  io = ''
  io << 'Element(' << @name << ', '
  if @attributes.any?
    io << @attributes.inspect
    io << ', '
  end
  io << @children.inspect
  io << ')'
  io
end