Class: RSMP::Query
- Inherits:
-
Object
- Object
- RSMP::Query
- Defined in:
- lib/rsmp/collect/query.rb
Overview
Class that matches a single status or command item
Direct Known Subclasses
Instance Attribute Summary collapse
-
#got ⇒ Object
readonly
Returns the value of attribute got.
-
#message ⇒ Object
readonly
Returns the value of attribute message.
-
#want ⇒ Object
readonly
Returns the value of attribute want.
Instance Method Summary collapse
-
#done? ⇒ Boolean
Are we done, i.e.
-
#initialize(want) ⇒ Query
constructor
A new instance of Query.
- #match?(item) ⇒ Boolean
-
#perform_match(item, message) ⇒ Object
Check an item and set @done to true if it matches Store the item and corresponding message if there's a positive or negative match.
Constructor Details
#initialize(want) ⇒ Query
Returns a new instance of Query.
7 8 9 10 11 12 |
# File 'lib/rsmp/collect/query.rb', line 7 def initialize want @want = want @got = nil @message = nil @done = false end |
Instance Attribute Details
#got ⇒ Object (readonly)
Returns the value of attribute got.
5 6 7 |
# File 'lib/rsmp/collect/query.rb', line 5 def got @got end |
#message ⇒ Object (readonly)
Returns the value of attribute message.
5 6 7 |
# File 'lib/rsmp/collect/query.rb', line 5 def @message end |
#want ⇒ Object (readonly)
Returns the value of attribute want.
5 6 7 |
# File 'lib/rsmp/collect/query.rb', line 5 def want @want end |
Instance Method Details
#done? ⇒ Boolean
Are we done, i.e. did the last checked item match?
15 16 17 |
# File 'lib/rsmp/collect/query.rb', line 15 def done? @done end |
#match?(item) ⇒ Boolean
31 32 |
# File 'lib/rsmp/collect/query.rb', line 31 def match? item end |
#perform_match(item, message) ⇒ Object
Check an item and set @done to true if it matches Store the item and corresponding message if there's a positive or negative match
21 22 23 24 25 26 27 28 29 |
# File 'lib/rsmp/collect/query.rb', line 21 def perform_match item, matched = match? item if matched != nil @message = @got = item @done = matched end matched end |