Class: Attest::ExpectationResult

Inherits:
Object
  • Object
show all
Includes:
Comparable
Defined in:
lib/attest/expectation_result.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ ExpectationResult

Returns a new instance of ExpectationResult.



16
17
18
19
# File 'lib/attest/expectation_result.rb', line 16

def initialize(attributes={})
  @outcome = nil
  @attributes = attributes
end

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



14
15
16
# File 'lib/attest/expectation_result.rb', line 14

def attributes
  @attributes
end

#source_locationObject

Returns the value of attribute source_location.



15
16
17
# File 'lib/attest/expectation_result.rb', line 15

def source_location
  @source_location
end

Class Method Details

.status_typesObject



5
6
7
# File 'lib/attest/expectation_result.rb', line 5

def status_types
  status_weights.keys
end

.status_weightsObject



9
10
11
# File 'lib/attest/expectation_result.rb', line 9

def status_weights
  {:success => 1, :failure => 2, :error => 3, :pending => 4, :disabled => 5}
end

Instance Method Details

#<=>(another_result) ⇒ Object



44
45
46
47
# File 'lib/attest/expectation_result.rb', line 44

def <=>(another_result)
  return 1 unless another_result
  self.status_weight <=> another_result.status_weight
end

#statusObject



32
33
34
# File 'lib/attest/expectation_result.rb', line 32

def status
  @outcome
end

#status_weightObject



40
41
42
# File 'lib/attest/expectation_result.rb', line 40

def status_weight
  Attest::ExpectationResult.status_weights[status.to_sym]
end

#update(attributes = {}) ⇒ Object



36
37
38
# File 'lib/attest/expectation_result.rb', line 36

def update(attributes={})
  @attributes.merge!(attributes)
end