Class: Keisan::AST::MultiLine

Inherits:
Parent show all
Defined in:
lib/keisan/ast/multi_line.rb

Instance Attribute Summary

Attributes inherited from Parent

#children

Instance Method Summary collapse

Methods inherited from Parent

#==, #deep_dup, #freeze, #initialize, #replace, #traverse, #unbound_functions, #unbound_variables

Methods inherited from Node

#!, #%, #&, #*, #**, #+, #+@, #-, #-@, #/, #<, #<<, #<=, #>, #>=, #>>, #^, #and, #coerce, #contains_a?, #deep_dup, #differentiate, #differentiated, #equal, #evaluated, #false?, #not_equal, #or, #replace, #replaced, #simplified, #to_cell, #to_node, #traverse, #true?, #unbound_functions, #unbound_variables, #well_defined?, #|, #~

Constructor Details

This class inherits a constructor from Keisan::AST::Parent

Instance Method Details

#evaluate(context = nil) ⇒ Object



13
14
15
16
17
# File 'lib/keisan/ast/multi_line.rb', line 13

def evaluate(context = nil)
  context ||= Context.new
  @children = children.map {|child| child.evaluate(context)}
  @children.last
end

#evaluate_assignments(context = nil) ⇒ Object



9
10
11
# File 'lib/keisan/ast/multi_line.rb', line 9

def evaluate_assignments(context = nil)
  self
end

#simplify(context = nil) ⇒ Object



19
20
21
# File 'lib/keisan/ast/multi_line.rb', line 19

def simplify(context = nil)
  evaluate(context)
end

#to_sObject



23
24
25
# File 'lib/keisan/ast/multi_line.rb', line 23

def to_s
  children.map(&:to_s).join(";")
end

#value(context = nil) ⇒ Object



4
5
6
7
# File 'lib/keisan/ast/multi_line.rb', line 4

def value(context = nil)
  context ||= Context.new
  evaluate(context).value(context)
end