Module: RPNCalculator

Defined in:
lib/rpn-calculator.rb,
lib/rpn-calculator/version.rb,
lib/rpn-calculator/input/parser.rb,
lib/rpn-calculator/io_processor.rb,
lib/rpn-calculator/result/parser.rb,
lib/rpn-calculator/operation/base.rb,
lib/rpn-calculator/input/validator.rb,
lib/rpn-calculator/result/operation.rb,
lib/rpn-calculator/result/processor.rb,
lib/rpn-calculator/result/validator.rb,
lib/rpn-calculator/operation/addition.rb,
lib/rpn-calculator/operation/division.rb,
lib/rpn-calculator/operation_processor.rb,
lib/rpn-calculator/io_interface/abstract.rb,
lib/rpn-calculator/io_interface/standard.rb,
lib/rpn-calculator/operation/subtraction.rb,
lib/rpn-calculator/operation/multiplication.rb

Defined Under Namespace

Modules: Input, IoInterface, Operation, Result Classes: IoProcessor, OperationProcessor

Constant Summary collapse

OPERATION_CLASSES =
{
  '+' => Operation::Addition,
  '-' => Operation::Subtraction,
  '*' => Operation::Multiplication,
  '/' => Operation::Division
}.freeze
ALLOWED_OPERATORS =
OPERATION_CLASSES.keys.freeze
INVALID_ARGUMENTS_REGEX =
/[^\d\s\+\-\/\*\.]/.freeze
VERSION =
'0.3.0'.freeze

Class Method Summary collapse

Class Method Details

.startObject



17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/rpn-calculator.rb', line 17

def start
  operation_processor = OperationProcessor.new(
    OPERATION_CLASSES,
    Input::Validator.new(INVALID_ARGUMENTS_REGEX),
    Input::Parser.new(ALLOWED_OPERATORS)
  )

  # Here is where we could read and write to another input
  # using stdin and stdout by default
  processor = IoProcessor.new(IoInterface::Standard.new, operation_processor)
  processor.start
end