class RPNCalculator::Operation::Base
Attributes
operands[R]
Public Class Methods
new(operands)
click to toggle source
# File lib/rpn-calculator/operation/base.rb, line 8 def initialize(operands) @operands = operands.compact end
operate(operands)
click to toggle source
# File lib/rpn-calculator/operation/base.rb, line 4 def self.operate(operands) new(operands).result end
Public Instance Methods
result()
click to toggle source
# File lib/rpn-calculator/operation/base.rb, line 12 def result raise 'must implement in subclass' end
Private Instance Methods
invalid_operation_result(operation)
click to toggle source
# File lib/rpn-calculator/operation/base.rb, line 24 def invalid_operation_result(operation) Result::Operation.new(operation, [], operands) end
operation_string()
click to toggle source
# File lib/rpn-calculator/operation/base.rb, line 28 def operation_string raise 'must implement in subclass' end
valid?()
click to toggle source
# File lib/rpn-calculator/operation/base.rb, line 20 def valid? operands.size == 2 end