Class: Yap::Shell::Parser::Nodes::StatementsNode

Inherits:
Object
  • Object
show all
Includes:
Visitor
Defined in:
lib/yap/shell/parser/nodes.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Visitor

#accept

Constructor Details

#initialize(head, tail = nil) ⇒ StatementsNode

Returns a new instance of StatementsNode.



140
141
142
143
144
145
146
147
# File 'lib/yap/shell/parser/nodes.rb', line 140

def initialize(head, tail=nil)
  if head.is_a?(StatementsNode) && head.tail.nil?
    @head = head.head
  else
    @head = head
  end
  @tail = tail
end

Instance Attribute Details

#headObject (readonly)

Returns the value of attribute head.



138
139
140
# File 'lib/yap/shell/parser/nodes.rb', line 138

def head
  @head
end

#tailObject (readonly)

Returns the value of attribute tail.



138
139
140
# File 'lib/yap/shell/parser/nodes.rb', line 138

def tail
  @tail
end

Instance Method Details

#inspectObject



157
158
159
# File 'lib/yap/shell/parser/nodes.rb', line 157

def inspect
  to_s
end

#to_s(indent: 0) ⇒ Object



149
150
151
152
153
154
155
# File 'lib/yap/shell/parser/nodes.rb', line 149

def to_s(indent:0)
  <<-EOT.gsub(/^\s+\|/, '')
    |  #{' ' * indent}StatementsNode(
    |  #{' ' * indent}  #{@head.to_s},
    |  #{' ' * indent}  #{@tail.to_s})
  EOT
end