class DBus::MatchRule
D-Bus match rule class¶ ↑
FIXME
Constants
- FILTERS
The list of possible match filters. TODO argN, argNpath
Attributes
The destination filter.
The interface filter.
The member filter.
The path filter.
The sender filter.
@return [String] The type type that is matched.
Public Class Methods
Create a new match rule
# File lib/dbus/matchrule.rb, line 36 def initialize @sender = @interface = @member = @path = @destination = @type = nil end
Public Instance Methods
Parses a match rule string s and sets the filters on the object.
# File lib/dbus/matchrule.rb, line 61 def from_s(str) str.split(",").each do |eq| next unless eq =~ /^(.*)='([^']*)'$/ # " name = Regexp.last_match(1) val = Regexp.last_match(2) raise MatchRuleException, name unless FILTERS.member?(name.to_sym) method("#{name}=").call(val) end self end
Sets the match rule to filter for the given signal and the given interface intf.
# File lib/dbus/matchrule.rb, line 77 def from_signal(intf, signal) signal = signal.name unless signal.is_a?(String) self.type = "signal" self.interface = intf.name self.member = signal self.path = intf.object.path self end
Determines whether a message msg matches the match rule.
# File lib/dbus/matchrule.rb, line 87 def match(msg) return false if @type && @type != msg.message_type_s return false if @interface && @interface != msg.interface return false if @member && @member != msg.member return false if @path && @path != msg.path # FIXME: sender and destination are ignored true end
Returns a match rule string version of the object. E.g.: “type='signal',sender='org.freedesktop.DBus',” + “interface='org.freedesktop.DBus',member='Foo',” + “path='/bar/foo',destination=':452345.34',arg2='bar'”
# File lib/dbus/matchrule.rb, line 54 def to_s present_rules = FILTERS.select { |sym| method(sym).call } present_rules.map! { |sym| "#{sym}='#{method(sym).call}'" } present_rules.join(",") end
Set the message types to filter to type typ. Possible message types are: signal, method_call, method_return, and error.
# File lib/dbus/matchrule.rb, line 42 def type=(typ) if !["signal", "method_call", "method_return", "error"].member?(typ) raise MatchRuleException, typ end @type = typ end