Class: MathExpression

Inherits:
Object
  • Object
show all
Defined in:
lib/Expression/parser.rb,
lib/Expression/getters.rb,
lib/Expression/identifiers.rb

Instance Method Summary collapse

Constructor Details

#initializeMathExpression

Returns a new instance of MathExpression.



9
10
11
12
# File 'lib/Expression/parser.rb', line 9

def initialize()
  @input = nil
  @look = nil
end

Instance Method Details

#eval(input) ⇒ Object



14
15
16
17
18
19
20
21
22
# File 'lib/Expression/parser.rb', line 14

def eval(input)
  @input = input
  init
  temp = calculate
  unless @look.nil?
    raise InvalidInput, "unexpected input: \"#{@look}\""
  end
  temp
end