Class: DBus::NodeTree

Inherits:
Object
  • Object
show all
Defined in:
lib/dbus/node_tree.rb

Overview

Has a tree of Nodes, refering to Objects or to ProxyObjects.

Direct Known Subclasses

ObjectServer, ProxyService

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeNodeTree

Returns a new instance of NodeTree.



18
19
20
# File 'lib/dbus/node_tree.rb', line 18

def initialize
  @root = Node.new("/")
end

Instance Attribute Details

#rootNode (readonly)

Returns:



16
17
18
# File 'lib/dbus/node_tree.rb', line 16

def root
  @root
end

Instance Method Details

#get_node(path, create: false) ⇒ Node?

Get the object node corresponding to the given path.

Parameters:

  • path (ObjectPath)
  • create (Boolean) (defaults to: false)

    if true, the the DBus::Nodes in the path are created if they do not already exist.

Returns:



27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/dbus/node_tree.rb', line 27

def get_node(path, create: false)
  n = @root
  path.sub(%r{^/}, "").split("/").each do |elem|
    if !(n[elem])
      return nil if !create

      n[elem] = Node.new(elem)
    end
    n = n[elem]
  end
  n
end