Class: RPNCalculator::Input::Parser

Inherits:
Object
  • Object
show all
Defined in:
lib/rpn-calculator/input/parser.rb

Instance Method Summary collapse

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