Class: ElseNode

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

Instance Attribute Summary collapse

Attributes inherited from Node

#value

Instance Method Summary collapse

Methods inherited from Node

#to_s

Constructor Details

#initialize(node) ⇒ ElseNode

Returns a new instance of ElseNode.



210
211
212
213
# File 'lib/nodes/stmtnodes.rb', line 210

def initialize(node)
  @node = node
  @argument = BoolNode.new(ScopeManager.true_value)
end

Instance Attribute Details

#argumentObject

Returns the value of attribute argument.



208
209
210
# File 'lib/nodes/stmtnodes.rb', line 208

def argument
  @argument
end

#nodeObject

Returns the value of attribute node.



208
209
210
# File 'lib/nodes/stmtnodes.rb', line 208

def node
  @node
end

Instance Method Details

#create_tree_entryObject



215
216
217
218
219
# File 'lib/nodes/stmtnodes.rb', line 215

def create_tree_entry
  result = set_up_scope_header
  result += "Else statement is used."
  TREE_ARRAY << result unless TREE_ARRAY[-1] == result
end

#evaluateObject



221
222
223
224
225
# File 'lib/nodes/stmtnodes.rb', line 221

def evaluate
  @value = @node.evaluate
  create_tree_entry if PRINT_TREE_FLAG
  @value
end