Class: Keisan::AST::LogicalOperator

Inherits:
Operator show all
Defined in:
lib/keisan/ast/logical_operator.rb

Constant Summary

Constants inherited from Operator

Operator::ARITIES, Operator::ARITY_PRIORITY_ASSOCIATIVITY, Operator::ASSOCIATIVITIES, Operator::ASSOCIATIVITY_OF_PRIORITY, Operator::PRIORITIES

Instance Attribute Summary

Attributes inherited from Parent

#children

Instance Method Summary collapse

Methods inherited from Operator

#arity, arity, #associativity, associativity, associativity_of_priority, #blank_value, #evaluate_assignments, #initialize, priority, #priority, symbol, #symbol, #to_s

Methods inherited from Parent

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

Methods inherited from Node

#!, #%, #&, #*, #**, #+, #+@, #-, #-@, #/, #<, #<<, #<=, #>, #>=, #>>, #^, #and, #coerce, #contains_a?, #deep_dup, #differentiate, #differentiated, #equal, #evaluate_assignments, #evaluated, #false?, #is_constant?, #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::Operator

Instance Method Details

#evaluate(context = nil) ⇒ Object



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

def evaluate(context = nil)
  context ||= Context.new
  children[0].evaluate(context).send(operator, children[1].evaluate(context))
end

#simplify(context = nil) ⇒ Object



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

def simplify(context = nil)
  context ||= Context.new
  children[0].simplify(context).send(operator, children[1].simplify(context))
end

#value(context = nil) ⇒ Object



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

def value(context=nil)
  context ||= Context.new
  children[0].value(context).send(value_operator, children[1].value(context))
end