Class: Calculator

Inherits:
Object
  • Object
show all
Defined in:
lib/it_tools/calc.rb

Instance Method Summary collapse

Constructor Details

#initializeCalculator

Returns a new instance of Calculator.



2
3
4
# File 'lib/it_tools/calc.rb', line 2

def initialize
  @stack = []
end

Instance Method Details

#addObject



11
12
13
# File 'lib/it_tools/calc.rb', line 11

def add
  @stack.push( @stack.pop + @stack.pop )
end

#enter(value) ⇒ Object



5
6
7
# File 'lib/it_tools/calc.rb', line 5

def enter( value ) 
  @stack.push value
end

#screenObject



8
9
10
# File 'lib/it_tools/calc.rb', line 8

def screen
  @stack[0]
end