Class: RSMP::Query

Inherits:
Object
  • Object
show all
Defined in:
lib/rsmp/collect/query.rb

Overview

Class that matches a single status or command item

Direct Known Subclasses

CommandQuery, StatusQuery

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#gotObject (readonly)

Returns the value of attribute got.



5
6
7
# File 'lib/rsmp/collect/query.rb', line 5

def got
  @got
end

#messageObject (readonly)

Returns the value of attribute message.



5
6
7
# File 'lib/rsmp/collect/query.rb', line 5

def message
  @message
end

#wantObject (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?

Returns:

  • (Boolean)


15
16
17
# File 'lib/rsmp/collect/query.rb', line 15

def done?
  @done
end

#match?(item) ⇒ Boolean

Returns:

  • (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, message
  matched = match? item
  if matched != nil
    @message = message
    @got = item
    @done = matched
  end
  matched
end