Class: StateMachineChecker::CheckResult

Inherits:
Object
  • Object
show all
Defined in:
lib/state_machine_checker/check_result.rb

Overview

The results of checking whether a given model satisfies a given formula.

Instance Method Summary collapse

Constructor Details

#initialize(result_hash) ⇒ CheckResult

Returns a new instance of CheckResult.

Parameters:


5
6
7
# File 'lib/state_machine_checker/check_result.rb', line 5

def initialize(result_hash)
  @result_hash = result_hash
end

Instance Method Details

#for_state(state) ⇒ StateResult

The result for a particular state.

Parameters:

  • state (Symbol)

Returns:


13
14
15
# File 'lib/state_machine_checker/check_result.rb', line 13

def for_state(state)
  result_hash[state]
end

#intersection(other) ⇒ Object


25
26
27
# File 'lib/state_machine_checker/check_result.rb', line 25

def intersection(other)
  map { |state, result| result.and(other.for_state(state)) }
end

#map(&block) ⇒ Object


29
30
31
32
33
34
# File 'lib/state_machine_checker/check_result.rb', line 29

def map(&block)
  entries = result_hash.map { |state, result|
    [state, block.yield(state, result)]
  }
  CheckResult.new(Hash[entries])
end

#to_hObject


17
18
19
# File 'lib/state_machine_checker/check_result.rb', line 17

def to_h
  result_hash.clone
end

#union(other) ⇒ Object


21
22
23
# File 'lib/state_machine_checker/check_result.rb', line 21

def union(other)
  map { |state, result| result.or(other.for_state(state)) }
end