Class: DBus::Node
- Inherits:
-
Hash
- Object
- Hash
- DBus::Node
- Defined in:
- lib/dbus/bus.rb
Overview
Object path node class
Class representing a node on an object path.
Instance Attribute Summary collapse
-
#name ⇒ String
readonly
The name of the node.
-
#object ⇒ DBus::Object, ...
The D-Bus object contained by the node.
Instance Method Summary collapse
-
#descendant_objects ⇒ Array<DBus::Object>
All objects (not paths) under this path (except itself).
-
#initialize(name) ⇒ Node
constructor
Create a new node with a given name.
-
#inspect ⇒ Object
Return inspect information of the node.
-
#sub_inspect ⇒ Object
Return instance inspect information, used by Node#inspect.
-
#to_xml(node_opath) ⇒ Object
Return an XML string representation of the node.
Constructor Details
#initialize(name) ⇒ Node
Create a new node with a given name.
195 196 197 198 199 |
# File 'lib/dbus/bus.rb', line 195 def initialize(name) super() @name = name @object = nil end |
Instance Attribute Details
#name ⇒ String (readonly)
The name of the node.
192 193 194 |
# File 'lib/dbus/bus.rb', line 192 def name @name end |
#object ⇒ DBus::Object, ...
Returns The D-Bus object contained by the node.
188 189 190 |
# File 'lib/dbus/bus.rb', line 188 def object @object end |
Instance Method Details
#descendant_objects ⇒ Array<DBus::Object>
All objects (not paths) under this path (except itself).
239 240 241 242 243 244 |
# File 'lib/dbus/bus.rb', line 239 def descendant_objects children_objects = values.map(&:object).compact descendants = values.map(&:descendant_objects) flat_descendants = descendants.reduce([], &:+) children_objects + flat_descendants end |
#inspect ⇒ Object
Return inspect information of the node.
220 221 222 223 |
# File 'lib/dbus/bus.rb', line 220 def inspect # Need something here "<DBus::Node #{sub_inspect}>" end |
#sub_inspect ⇒ Object
Return instance inspect information, used by Node#inspect.
226 227 228 229 230 231 232 233 234 235 |
# File 'lib/dbus/bus.rb', line 226 def sub_inspect s = "" if !@object.nil? s += format("%x ", @object.object_id) end contents_sub_inspect = keys .map { |k| "#{k} => #{self[k].sub_inspect}" } .join(",") "#{s}{#{contents_sub_inspect}}" end |
#to_xml(node_opath) ⇒ Object
Return an XML string representation of the node. It is shallow, not recursing into subnodes
204 205 206 207 208 209 210 211 212 213 214 215 216 217 |
# File 'lib/dbus/bus.rb', line 204 def to_xml(node_opath) xml = '<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd"> ' xml += "<node name=\"#{node_opath}\">\n" each_key do |k| xml += " <node name=\"#{k}\" />\n" end @object&.intfs&.each_value do |v| xml += v.to_xml end xml += "</node>" xml end |