class DBus::Node

Object path node class

Class representing a node on an object path.

Attributes

name[R]

The name of the node. @return [String] the last component of its object path, or “/”

object[RW]

@return [DBus::Object,DBus::ProxyObject,nil]

The D-Bus object contained by the node.

Public Class Methods

new(name) click to toggle source

Create a new node with a given name.

Calls superclass method
   # File lib/dbus/node_tree.rb
54 def initialize(name)
55   super()
56   @name = name
57   @object = nil
58 end

Public Instance Methods

descendant_objects() click to toggle source

All objects (not paths) under this path (except itself). @return [Array<DBus::Object>]

    # File lib/dbus/node_tree.rb
 98 def descendant_objects
 99   children_objects = values.map(&:object).compact
100   descendants = values.map(&:descendant_objects)
101   flat_descendants = descendants.reduce([], &:+)
102   children_objects + flat_descendants
103 end
inspect() click to toggle source

Return inspect information of the node.

   # File lib/dbus/node_tree.rb
79 def inspect
80   # Need something here
81   "<DBus::Node #{sub_inspect}>"
82 end
sub_inspect() click to toggle source

Return instance inspect information, used by Node#inspect.

   # File lib/dbus/node_tree.rb
85 def sub_inspect
86   s = ""
87   if !@object.nil?
88     s += format("%x ", @object.object_id)
89   end
90   contents_sub_inspect = keys
91                          .map { |k| "#{k} => #{self[k].sub_inspect}" }
92                          .join(",")
93   "#{s}{#{contents_sub_inspect}}"
94 end
to_xml(node_opath) click to toggle source

Return an XML string representation of the node. It is shallow, not recursing into subnodes @param node_opath [String]

   # File lib/dbus/node_tree.rb
63     def to_xml(node_opath)
64       xml = '<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN"
65 "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
66 '
67       xml += "<node name=\"#{node_opath}\">\n"
68       each_key do |k|
69         xml += "  <node name=\"#{k}\" />\n"
70       end
71       @object&.intfs&.each_value do |v|
72         xml += v.to_xml
73       end
74       xml += "</node>"
75       xml
76     end