Class: DMark::Nodes::TextNode

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(text:) ⇒ TextNode

Returns a new instance of TextNode.



32
33
34
35
# File 'lib/dmark/nodes.rb', line 32

def initialize(text:)
  super()
  @text = text
end

Instance Attribute Details

#textObject (readonly)

Returns the value of attribute text.



30
31
32
# File 'lib/dmark/nodes.rb', line 30

def text
  @text
end

Instance Method Details

#inspect(indent = 0) ⇒ Object



37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/dmark/nodes.rb', line 37

def inspect(indent = 0)
  io = ''
  io << '  ' * indent
  io << 'Text('
  io << @text.inspect
  io << "\n" if children.any?
  children.each { |c| io << c.inspect(indent + 1) }
  io << '  ' * indent if children.any?
  io << ')'
  io << "\n"
  io
end