Class: Arithmetic::Expression
- Inherits:
-
Object
- Object
- Arithmetic::Expression
- Defined in:
- lib/arithmetic/expression.rb
Instance Method Summary collapse
- #eval ⇒ Object
-
#initialize(expression) ⇒ Expression
constructor
A new instance of Expression.
- #to_s(visitor = identity_function) ⇒ Object
Constructor Details
#initialize(expression) ⇒ Expression
Returns a new instance of Expression.
3 4 5 |
# File 'lib/arithmetic/expression.rb', line 3 def initialize(expression) @parsed_expression = expression end |
Instance Method Details
#eval ⇒ Object
7 8 9 |
# File 'lib/arithmetic/expression.rb', line 7 def eval @result ||= @parsed_expression.eval end |
#to_s(visitor = identity_function) ⇒ Object
11 12 13 |
# File 'lib/arithmetic/expression.rb', line 11 def to_s(visitor=identity_function) @string ||= @parsed_expression.to_s(visitor) end |