class Basic101::BinaryOperation
Public Class Methods
new(operator, right)
click to toggle source
# File lib/basic101/binary_operation.rb, line 11 def initialize(operator, right) @operator = operator @right = right end
Public Instance Methods
operate(left, runtime)
click to toggle source
# File lib/basic101/binary_operation.rb, line 16 def operate(left, runtime) if @operator.is_a?(Symbol) left_value = left.eval(runtime) right_value = @right.eval(runtime) left_value.public_send(@operator, right_value) else @operator.operate(left, @right, runtime) end end
Protected Instance Methods
state()
click to toggle source
# File lib/basic101/binary_operation.rb, line 28 def state [@operator, @right] end