Class: DBus::Service
- Inherits:
-
Object
- Object
- DBus::Service
- Defined in:
- lib/dbus/bus.rb
Overview
This represents a remote service. It should not be instantiated 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 (ProxyObject) at the given path.
Constructor Details
#initialize(name, bus) ⇒ Service
Create a new service with a given name on a given bus.
30 31 32 33 |
# File 'lib/dbus/bus.rb', line 30 def initialize(name, bus) @name, @bus = name, bus @root = Node.new("/") end |
Instance Attribute Details
#bus ⇒ Object (readonly)
The bus the service is running on.
25 26 27 |
# File 'lib/dbus/bus.rb', line 25 def bus @bus end |
#name ⇒ Object (readonly)
The service name.
23 24 25 |
# File 'lib/dbus/bus.rb', line 23 def name @name end |
#root ⇒ Object (readonly)
The service root (FIXME).
27 28 29 |
# File 'lib/dbus/bus.rb', line 27 def root @root end |
Instance Method Details
#exists? ⇒ Boolean
Determine whether the service name already exists.
36 37 38 |
# File 'lib/dbus/bus.rb', line 36 def exists? bus.proxy.ListNames[0].member?(@name) end |
#export(obj) ⇒ Object
Export an object obj (an DBus::Object subclass instance).
61 62 63 64 |
# File 'lib/dbus/bus.rb', line 61 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.
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/dbus/bus.rb', line 68 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? puts "Warning, unknown object #{path}" if $DEBUG end n end |
#introspect ⇒ Object
Perform an introspection on all the objects on the service (starting recursively from the root).
42 43 44 45 46 47 48 49 |
# File 'lib/dbus/bus.rb', line 42 def introspect if block_given? raise NotImplementedError else rec_introspect(@root, "/") end self end |
#object(path) ⇒ Object
Retrieves an object (ProxyObject) at the given path.
52 53 54 55 56 57 58 |
# File 'lib/dbus/bus.rb', line 52 def object(path) node = get_node(path, true) if node.object.nil? node.object = ProxyObject.new(@bus, @name, path) end node.object end |