Class: DBus::Interface
- Inherits:
-
Object
- Object
- DBus::Interface
- Defined in:
- lib/dbus/introspect.rb
Overview
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
Instance Attribute Summary collapse
-
#methods ⇒ Object
readonly
The methods that are part of the interface.
-
#name ⇒ Object
readonly
The name of the interface.
-
#signals ⇒ Object
readonly
The signals that are part of the interface.
Instance Method Summary collapse
-
#define(m) ⇒ Object
(also: #<<)
Helper method for defining a method m.
-
#define_method(id, prototype) ⇒ Object
Defines a method with name id and a given prototype in the interface.
-
#initialize(name) ⇒ Interface
constructor
Creates a new interface with a given name.
-
#validate_name(name) ⇒ Object
Validates a service name.
Constructor Details
Instance Attribute Details
#methods ⇒ Object (readonly)
The methods that are part of the interface. Hash: Symbol => DBus::Method
36 37 38 |
# File 'lib/dbus/introspect.rb', line 36 def methods @methods end |
#name ⇒ Object (readonly)
The name of the interface. String
34 35 36 |
# File 'lib/dbus/introspect.rb', line 34 def name @name end |
#signals ⇒ Object (readonly)
The signals that are part of the interface. Hash: Symbol => Signal
38 39 40 |
# File 'lib/dbus/introspect.rb', line 38 def signals @signals end |
Instance Method Details
#define(m) ⇒ Object Also known as: <<
Helper method for defining a method m.
59 60 61 62 63 64 65 |
# File 'lib/dbus/introspect.rb', line 59 def define(m) if m.kind_of?(Method) @methods[m.name.to_sym] = m elsif m.kind_of?(Signal) @signals[m.name.to_sym] = m end end |
#define_method(id, prototype) ⇒ Object
Defines a method with name id and a given prototype in the interface.
70 71 72 73 74 |
# File 'lib/dbus/introspect.rb', line 70 def define_method(id, prototype) m = Method.new(id) m.from_prototype(prototype) define(m) end |
#validate_name(name) ⇒ Object
Validates a service name.
48 49 50 51 52 53 54 55 56 |
# File 'lib/dbus/introspect.rb', line 48 def validate_name(name) raise InvalidIntrospectionData if name.bytesize > 255 raise InvalidIntrospectionData if name =~ /^\./ or name =~ /\.$/ raise InvalidIntrospectionData if name =~ /\.\./ raise InvalidIntrospectionData if not name =~ /\./ name.split(".").each do |element| raise InvalidIntrospectionData if not element =~ InterfaceElementRE end end |