class Keisan::AST::LogicalAnd
Public Class Methods
symbol()
click to toggle source
# File lib/keisan/ast/logical_and.rb, line 4 def self.symbol :"&&" end
Public Instance Methods
blank_value()
click to toggle source
# File lib/keisan/ast/logical_and.rb, line 8 def blank_value true end
evaluate(context = nil)
click to toggle source
# File lib/keisan/ast/logical_and.rb, line 12 def evaluate(context = nil) short_circuit_do(:evaluate, context) end
simplify(context = nil)
click to toggle source
# File lib/keisan/ast/logical_and.rb, line 16 def simplify(context = nil) short_circuit_do(:simplify, context) end
value(context = nil)
click to toggle source
# File lib/keisan/ast/logical_and.rb, line 20 def value(context = nil) context ||= Context.new children[0].value(context) && children[1].value(context) end
Private Instance Methods
short_circuit_do(method, context)
click to toggle source
# File lib/keisan/ast/logical_and.rb, line 27 def short_circuit_do(method, context) context ||= Context.new lhs = children[0].send(method, context).to_node case lhs when AST::Boolean lhs.false? ? AST::Boolean.new(false) : children[1].send(method, context) else lhs.and(children[1].send(method, context)) end end