Class: DBus::Service
- Inherits:
-
Object
- Object
- DBus::Service
- Defined in:
- lib/dbus/bus.rb
Overview
This represents a remote service. It should not be instancied directly Use Bus::service()
Instance Attribute Summary collapse
-
#bus ⇒ Object
readonly
The bus the service is running on.
-
#name ⇒ Object
readonly
The service name.
-
#root ⇒ Object
readonly
The service root (FIXME).
Instance Method Summary collapse
-
#exists? ⇒ Boolean
Determine whether the service name already exists.
-
#export(obj) ⇒ Object
Export an object obj (an DBus::Object subclass instance).
-
#get_node(path, create = false) ⇒ Object
Get the object node corresponding to the given path.
-
#initialize(name, bus) ⇒ Service
constructor
Create a new service with a given name on a given bus.
-
#introspect ⇒ Object
Perform an introspection on all the objects on the service (starting recursively from the root).
-
#object(path) ⇒ Object
Retrieves an object at the given path.
Constructor Details
Instance Attribute Details
#bus ⇒ Object (readonly)
The bus the service is running on.
24 25 26 |
# File 'lib/dbus/bus.rb', line 24 def bus @bus end |
#name ⇒ Object (readonly)
The service name.
22 23 24 |
# File 'lib/dbus/bus.rb', line 22 def name @name end |
Instance Method Details
#exists? ⇒ Boolean
Determine whether the service name already exists.
35 36 37 |
# File 'lib/dbus/bus.rb', line 35 def exists? bus.proxy.ListNames[0].member?(@name) end |
#export(obj) ⇒ Object
Export an object obj (an DBus::Object subclass instance).
60 61 62 63 |
# File 'lib/dbus/bus.rb', line 60 def export(obj) obj.service = self get_node(obj.path, true).object = obj end |
#get_node(path, create = false) ⇒ Object
Get the object node corresponding to the given path. if create is true, the the nodes in the path are created if they do not already exist.
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/dbus/bus.rb', line 67 def get_node(path, create = false) n = @root path.sub(/^\//, "").split("/").each do |elem| if not n[elem] if not create return nil else n[elem] = Node.new(elem) end end n = n[elem] end if n.nil? wlog "Unknown object #{path.inspect}" end n end |
#introspect ⇒ Object
Perform an introspection on all the objects on the service (starting recursively from the root).
41 42 43 44 45 46 47 48 |
# File 'lib/dbus/bus.rb', line 41 def introspect if block_given? raise NotImplementedError else rec_introspect(@root, "/") end self end |
#object(path) ⇒ Object
Retrieves an object at the given path.
51 52 53 54 55 56 57 |
# File 'lib/dbus/bus.rb', line 51 def object(path) node = get_node(path, true) if node.object.nil? node.object = ProxyObject.new(@bus, @name, path) end node.object end |