Class: Keisanjaku::ProcedureChecker
- Inherits:
-
Object
- Object
- Keisanjaku::ProcedureChecker
- Defined in:
- lib/keisanjaku/procedure.rb
Constant Summary collapse
- VALUE_TOLERANCE =
1e-9
Instance Method Summary collapse
- #expected_events(plan) ⇒ Object
- #matches?(plan, attempt) ⇒ Boolean
- #observed_events(attempt) ⇒ Object
Instance Method Details
#expected_events(plan) ⇒ Object
84 85 86 |
# File 'lib/keisanjaku/procedure.rb', line 84 def expected_events(plan) plan.steps.map { |step| ProcedureEvent.from_step(step) } end |
#matches?(plan, attempt) ⇒ Boolean
75 76 77 78 79 80 81 82 |
# File 'lib/keisanjaku/procedure.rb', line 75 def matches?(plan, attempt) return false if attempt.used_model expected = expected_events(plan) observed = observed_events(attempt) expected.length == observed.length && expected.zip(observed).all? { |expected_event, observed_event| event_matches?(expected_event, observed_event) } end |
#observed_events(attempt) ⇒ Object
88 89 90 |
# File 'lib/keisanjaku/procedure.rb', line 88 def observed_events(attempt) attempt.actions.filter { |action| action.is_a?(ProcedureEvent) } end |