Class: Spectre::Assertion::Evaluation

Inherits:
Object
  • Object
show all
Defined in:
lib/spectre/assertion.rb

Direct Known Subclasses

AndEvaluation, OrEvaluation

Instance Method Summary collapse

Constructor Details

#initialize(val) ⇒ Evaluation

Returns a new instance of Evaluation.



179
180
181
# File 'lib/spectre/assertion.rb', line 179

def initialize val
  @val = val
end

Instance Method Details

#evaluate(val, predicate) ⇒ Object



187
188
189
190
191
192
193
# File 'lib/spectre/assertion.rb', line 187

def evaluate(val, predicate)
  if val.is_a? Evaluation
    val.run &predicate
  else
    predicate.call(val)
  end
end

#run(&block) ⇒ Object



183
184
185
# File 'lib/spectre/assertion.rb', line 183

def run &block
  evaluate(@val, block)
end

#to_sObject



195
196
197
# File 'lib/spectre/assertion.rb', line 195

def to_s
  @val.to_s
end