Sha256: e87acec0986e2cbef8234489b567fa27f6bee577f6578405e89d2d7805c68868

Contents?: true

Size: 348 Bytes

Versions: 8

Compression:

Stored size: 348 Bytes

Contents

# encoding: utf-8

class Calculator
  def initialize
    @stack = []
  end

  def push(arg)
    @stack.push arg
  end

  def result
    @stack.last
  end

  def +
    @stack.push @stack.pop + @stack.pop
  end

  def /
    divisor, dividend = [@stack.pop, @stack.pop]
    # Hm, @stack.pop(2) doesn't work
    @stack.push dividend / divisor
  end
end

Version data entries

8 entries across 2 versions & 1 rubygems

Version Path
cucumber-3.0.1 examples/i18n/ru/lib/calculator.rb
cucumber-3.0.1 examples/i18n/uz/lib/calculator.rb
cucumber-3.0.1 examples/i18n/bg/lib/calculator.rb
cucumber-3.0.1 examples/i18n/uk/lib/calculator.rb
cucumber-3.0.0 examples/i18n/bg/lib/calculator.rb
cucumber-3.0.0 examples/i18n/uz/lib/calculator.rb
cucumber-3.0.0 examples/i18n/uk/lib/calculator.rb
cucumber-3.0.0 examples/i18n/ru/lib/calculator.rb