class DBus::Interface
D-Bus interface class¶ ↑
This class is the interface descriptor. In most cases, the Introspect() method call instantiates and configures this class for us.
It also is the local definition of interface exported by the program. At the client side, see ProxyObjectInterface
Attributes
methods[R]
The methods that are part of the interface. Hash: Symbol => DBus::Method
name[R]
The name of the interface. String
signals[R]
The signals that are part of the interface. Hash: Symbol => Signal
Public Class Methods
new(name)
click to toggle source
Creates a new interface with a given name.
# File lib/dbus/introspect.rb 37 def initialize(name) 38 validate_name(name) 39 @name = name 40 @methods = {} 41 @signals = {} 42 end
Public Instance Methods
define(m)
click to toggle source
Helper method for defining a method m.
# File lib/dbus/introspect.rb 56 def define(m) 57 if m.is_a?(Method) 58 @methods[m.name.to_sym] = m 59 elsif m.is_a?(Signal) 60 @signals[m.name.to_sym] = m 61 end 62 end
Also aliased as: <<
define_method(id, prototype)
click to toggle source
Defines a method with name id and a given prototype in the interface.
# File lib/dbus/introspect.rb 67 def define_method(id, prototype) 68 m = Method.new(id) 69 m.from_prototype(prototype) 70 define(m) 71 end
validate_name(name)
click to toggle source
Validates a service name.
# File lib/dbus/introspect.rb 45 def validate_name(name) 46 raise InvalidIntrospectionData if name.bytesize > 255 47 raise InvalidIntrospectionData if name =~ /^\./ || name =~ /\.$/ 48 raise InvalidIntrospectionData if name =~ /\.\./ 49 raise InvalidIntrospectionData if name !~ /\./ 50 name.split(".").each do |element| 51 raise InvalidIntrospectionData if element !~ INTERFACE_ELEMENT_RE 52 end 53 end