Class: RSMP::CommandQuery

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

Overview

Match a specific command responses

Instance Attribute Summary

Attributes inherited from Query

#got, #message, #want

Instance Method Summary collapse

Methods inherited from Query

#done?, #forget, #initialize, #keep, #perform_match

Constructor Details

This class inherits a constructor from RSMP::Query

Instance Method Details

#match?(item) ⇒ Boolean

Match a return value item against a query

Returns:

  • (Boolean)


5
6
7
8
9
10
11
12
13
14
# File 'lib/rsmp/collect/command_query.rb', line 5

def match? item
  return nil if @want['cCI'] && @want['cCI'] != item['cCI']
  return nil if @want['n'] && @want['n'] != item['n']
  if @want['v'].is_a? Regexp
    return false if @want['v'] && item['v'] !~ @want['v']
  else
    return false if @want['v'] && item['v'] != @want['v']
  end
  true
end