Module: RPNCalculator
- Defined in:
- lib/rpn-calculator.rb,
lib/rpn-calculator/cli.rb,
lib/rpn-calculator/version.rb,
lib/rpn-calculator/input/parser.rb,
lib/rpn-calculator/result/input.rb,
lib/rpn-calculator/result/parser.rb,
lib/rpn-calculator/operation/base.rb,
lib/rpn-calculator/input/validator.rb,
lib/rpn-calculator/input_processor.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: CLI, InputProcessor, 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\.#{Regexp.quote(ALLOWED_OPERATORS.join)}]/
- OPERATION_PROCESSOR =
OperationProcessor.new(OPERATION_CLASSES).freeze
- INPUT_PROCESSOR =
InputProcessor.new(
OPERATION_PROCESSOR,
Input::Validator.new(INVALID_ARGUMENTS_REGEX),
Input::Parser.new(ALLOWED_OPERATORS)
).freeze
- VERSION =
'0.4.0'.freeze
Class Method Summary
collapse
Class Method Details
.calculate(expression) ⇒ Object
30
31
32
|
# File 'lib/rpn-calculator.rb', line 30
def calculate(expression)
INPUT_PROCESSOR.process(expression)
end
|