Sha256: e3c70875aa76daf61cb613c518f02825d143fdace61d5c0bb5de526ad9e07b67

Contents?: true

Size: 715 Bytes

Versions: 1

Compression:

Stored size: 715 Bytes

Contents

module Glimmer
  class Calculator
    class Command
      class Operation < Command      
        class Multiply < Operation
          keywords '×', '*'

          def execute          
            if number2 && operation && !last_command.equals?
              self.result = operation.calculate.to_s            
              self.number1 = self.result
            else
              self.result = last_result
              self.operation = self
            end
          end
          
          def calculate
            calculation_result = number1 * number2
            calculation_result.to_s.match(/\.0+$/) ? calculation_result.to_i : calculation_result
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
glimmer-cs-calculator-1.0.0 lib/models/glimmer/calculator/command/operation/multiply.rb