Class: RSMP::Validator::Helpers::SignalPriority::S0033Matcher
- Inherits:
-
StatusMatcher
- Object
- StatusMatcher
- RSMP::Validator::Helpers::SignalPriority::S0033Matcher
- Defined in:
- lib/rsmp/validator/helpers/signal_priority.rb
Overview
Match a specific status response or update
Instance Attribute Summary collapse
-
#state ⇒ Object
Returns the value of attribute state.
Instance Method Summary collapse
- #find_request_state(list) ⇒ Object
-
#initialize(want, request_id:, state: nil) ⇒ S0033Matcher
constructor
A new instance of S0033Matcher.
- #match(item) ⇒ Object
Constructor Details
#initialize(want, request_id:, state: nil) ⇒ S0033Matcher
Returns a new instance of S0033Matcher.
11 12 13 14 15 16 |
# File 'lib/rsmp/validator/helpers/signal_priority.rb', line 11 def initialize(want, request_id:, state: nil) super(want) @request_id = request_id @state = state @latest_state = nil end |
Instance Attribute Details
#state ⇒ Object
Returns the value of attribute state.
9 10 11 |
# File 'lib/rsmp/validator/helpers/signal_priority.rb', line 9 def state @state end |
Instance Method Details
#find_request_state(list) ⇒ Object
33 34 35 36 |
# File 'lib/rsmp/validator/helpers/signal_priority.rb', line 33 def find_request_state(list) priority = list.find { |prio| prio['r'] == @request_id } priority['s'] if priority end |
#match(item) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/rsmp/validator/helpers/signal_priority.rb', line 18 def match(item) super_matched = super if super_matched == true state = find_request_state item['s'] if state == @state.to_s && state != @latest_state @latest_state = state true else false end else super_matched end end |