Class: DMark::Nodes::ElementNode

Inherits:
Node
  • Object
show all
Defined in:
lib/dmark/nodes.rb

Instance Attribute Summary collapse

Attributes inherited from Node

#children

Instance Method Summary collapse

Constructor Details

#initialize(name:, attributes:) ⇒ ElementNode

Returns a new instance of ElementNode.



55
56
57
58
59
# File 'lib/dmark/nodes.rb', line 55

def initialize(name:, attributes:)
  super()
  @name = name
  @attributes = attributes
end

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



53
54
55
# File 'lib/dmark/nodes.rb', line 53

def attributes
  @attributes
end

#nameObject (readonly)

Returns the value of attribute name.



52
53
54
# File 'lib/dmark/nodes.rb', line 52

def name
  @name
end

Instance Method Details

#inspect(indent = 0) ⇒ Object



61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/dmark/nodes.rb', line 61

def inspect(indent = 0)
  io = ''
  io << '  ' * indent
  io << 'Element('
  io << @name
  io << ',' << @attributes.inspect unless @attributes.empty?
  io << "\n" if children.any?
  children.each { |c| io << c.inspect(indent + 1) }
  io << '  ' * indent if children.any?
  io << ')'
  io << "\n"
  io
end