Module: ReversePolishCalculator
- Defined in:
- lib/reverse-polish-calculator.rb,
lib/reverse-polish-calculator/input.rb,
lib/reverse-polish-calculator/stack.rb,
lib/reverse-polish-calculator/errors.rb,
lib/reverse-polish-calculator/inputs.rb,
lib/reverse-polish-calculator/output.rb,
lib/reverse-polish-calculator/helpers.rb,
lib/reverse-polish-calculator/version.rb
Defined Under Namespace
Modules: Errors, Helpers, Inputs, Output
Classes: Input, Stack
Constant Summary
collapse
- VERSION =
'0.0.1'
Class Method Summary
collapse
Class Method Details
.loop_with_error_handling ⇒ Object
22
23
24
25
26
27
28
29
|
# File 'lib/reverse-polish-calculator.rb', line 22
def self.loop_with_error_handling
loop { yield }
rescue *Errors::Classes => exception
Errors.handle(exception)
Output.clear
stack.unswap
retry
end
|
.stack ⇒ Object
18
19
20
|
# File 'lib/reverse-polish-calculator.rb', line 18
def self.stack
@stack ||= Stack.new
end
|
.start ⇒ Object
10
11
12
13
14
15
16
|
# File 'lib/reverse-polish-calculator.rb', line 10
def self.start
loop_with_error_handling do
stack.add(gets.chomp)
stack.calculate
stack.output
end
end
|