Class: RPNCalculator::Input::Parser
- Inherits:
-
Object
- Object
- RPNCalculator::Input::Parser
- Defined in:
- lib/rpn-calculator/input/parser.rb
Instance Method Summary collapse
-
#initialize(allowed_operators) ⇒ Parser
constructor
A new instance of Parser.
- #parse(input_string) ⇒ Object
Constructor Details
#initialize(allowed_operators) ⇒ Parser
Returns a new instance of Parser.
4 5 6 |
# File 'lib/rpn-calculator/input/parser.rb', line 4 def initialize(allowed_operators) @allowed_operators = allowed_operators end |
Instance Method Details
#parse(input_string) ⇒ Object
8 9 10 11 12 13 14 |
# File 'lib/rpn-calculator/input/parser.rb', line 8 def parse(input_string) parsed_input = input_without_whitespace( join_consecutive_numbers(input_string.split('')) ) invalid_elements = parsed_input_errors(parsed_input) Result::Parser.new(parsed_input, invalid_elements) end |