Class: Dest::Evaluator
- Inherits:
-
Object
- Object
- Dest::Evaluator
- Defined in:
- lib/dest/evaluator.rb
Instance Method Summary collapse
-
#evaluate ⇒ Object
Evaluates a doctest to see if the expression matches the result.
-
#initialize(parsed_attributes) ⇒ Evaluator
constructor
A new instance of Evaluator.
Constructor Details
#initialize(parsed_attributes) ⇒ Evaluator
Returns a new instance of Evaluator.
10 11 12 |
# File 'lib/dest/evaluator.rb', line 10 def initialize(parsed_attributes) @parsed_attributes = parsed_attributes end |
Instance Method Details
#evaluate ⇒ Object
Evaluates a doctest to see if the expression matches the result. Only true is returned if it matches as the formatter is only going to print out a dot. False provides the needed details for the formatter.
19 20 21 22 23 24 25 26 27 28 |
# File 'lib/dest/evaluator.rb', line 19 def evaluate expr_result = eval(@parsed_attributes[1]) if expr_result == eval(@parsed_attributes[2]) [true] else [false, @parsed_attributes[0], @parsed_attributes[1], @parsed_attributes[2], expr_result] # false, line number, expression, expected_result, actual_result end end |