Class: Sapphire::DSL::Evaluation

Inherits:
Object
  • Object
show all
Defined in:
lib/sapphire/DSL/Evaluations/Evaluation.rb

Direct Known Subclasses

ControlEvaluation

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#leftObject

Returns the value of attribute left.



5
6
7
# File 'lib/sapphire/DSL/Evaluations/Evaluation.rb', line 5

def left
  @left
end

#rightObject

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

#EvaluateObject



26
27
28
# File 'lib/sapphire/DSL/Evaluations/Evaluation.rb', line 26

def Evaluate()
  Compare(@left, @right)
end

#executeObject



22
23
24
# File 'lib/sapphire/DSL/Evaluations/Evaluation.rb', line 22

def execute()
  self.Output()
end

#Failed(control) ⇒ Object

Raises:

  • (ExpectationException)


40
41
42
43
44
45
46
47
48
49
# File 'lib/sapphire/DSL/Evaluations/Evaluation.rb', line 40

def Failed(control)
  messages = []

  messages << "expected" + @comparator.Text + ": (nil)" if @right == nil
  messages << "expected" + @comparator.Text + ": " + @right.to_s if @right != nil
  messages << "got: (nil)" if @left == nil
  messages << "got: " + @left.to_s if @left != nil

  raise ExpectationException.new(messages)
end

#OutputObject



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