Class: Sapphire::DSL::Evaluation
- Defined in:
- lib/sapphire/DSL/Evaluations/Evaluation.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#left ⇒ Object
Returns the value of attribute left.
-
#right ⇒ Object
Returns the value of attribute right.
Instance Method Summary collapse
- #Compare(left, right) ⇒ Object
- #CompareWith(item) ⇒ Object
- #Evaluate ⇒ Object
- #execute ⇒ Object
- #Failed(control) ⇒ Object
-
#initialize(left, right) ⇒ Evaluation
constructor
A new instance of Evaluation.
- #Output ⇒ Object
- #Passed(control) ⇒ Object
Constructor Details
#initialize(left, right) ⇒ Evaluation
Returns a new instance of Evaluation.
8 9 10 11 |
# File 'lib/sapphire/DSL/Evaluations/Evaluation.rb', line 8 def initialize(left, right) @left = left @right = right end |
Instance Attribute Details
#left ⇒ Object
Returns the value of attribute left.
5 6 7 |
# File 'lib/sapphire/DSL/Evaluations/Evaluation.rb', line 5 def left @left end |
#right ⇒ Object
Returns the value of attribute right.
6 7 8 |
# File 'lib/sapphire/DSL/Evaluations/Evaluation.rb', line 6 def right @right end |
Instance Method Details
#Compare(left, right) ⇒ Object
13 14 15 16 |
# File 'lib/sapphire/DSL/Evaluations/Evaluation.rb', line 13 def Compare(left, right) return @comparator.Compare(left, right) if @comparator != nil EqualsComparison.new(self).Compare(left, right) if @comparator == nil end |
#CompareWith(item) ⇒ Object
18 19 20 |
# File 'lib/sapphire/DSL/Evaluations/Evaluation.rb', line 18 def CompareWith(item) @comparator = item end |
#Evaluate ⇒ Object
26 27 28 |
# File 'lib/sapphire/DSL/Evaluations/Evaluation.rb', line 26 def Evaluate() Compare(@left, @right) end |
#execute ⇒ Object
22 23 24 |
# File 'lib/sapphire/DSL/Evaluations/Evaluation.rb', line 22 def execute() self.Output() end |
#Failed(control) ⇒ Object
40 41 42 43 44 45 46 47 48 49 |
# File 'lib/sapphire/DSL/Evaluations/Evaluation.rb', line 40 def Failed(control) = [] << "expected" + @comparator.Text + ": (nil)" if @right == nil << "expected" + @comparator.Text + ": " + @right.to_s if @right != nil << "got: (nil)" if @left == nil << "got: " + @left.to_s if @left != nil raise ExpectationException.new() end |
#Output ⇒ Object
30 31 32 33 34 35 36 37 38 |
# File 'lib/sapphire/DSL/Evaluations/Evaluation.rb', line 30 def Output() if(!Compare(@left, @right)) self.Failed(@control) else self.Passed(@control) end end |
#Passed(control) ⇒ Object
51 52 53 |
# File 'lib/sapphire/DSL/Evaluations/Evaluation.rb', line 51 def Passed(control) end |