Class: RSMP::CommandMatcher

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

Overview

Match a specific command responses

Instance Attribute Summary

Attributes inherited from Matcher

#got, #message, #want

Instance Method Summary collapse

Methods inherited from Matcher

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

Constructor Details

This class inherits a constructor from RSMP::Matcher

Instance Method Details

#match?(item) ⇒ Boolean

Match a return value item against a matcher

Returns:

  • (Boolean)


5
6
7
8
9
10
11
12
13
14
# File 'lib/rsmp/collect/command_matcher.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