# class DBus::Node

# `Object` path node class¶ ↑

`Class` representing a node on an object path.

### Attributes

name[R]

The name of the node.

object[RW]

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.

        # File lib/dbus/bus.rb
    144 def initialize(name)
    145   @name = name
    146   @object = nil
    147 end

### Public Instance Methods

inspect() click to toggle source

Return inspect information of the node.

        # File lib/dbus/bus.rb
    172 def inspect
    173   # Need something here
    174   "<DBus::Node #{sub_inspect}>"
    175 end

sub_inspect() click to toggle source

Return instance inspect information, used by `Node#inspect`.

        # File lib/dbus/bus.rb
    178 def sub_inspect
    179   s = ""
    180   if !@object.nil?
    181     s += format("%x ", @object.object_id)
    182   end
    183   s + "{" + keys.collect { |k| "#{k} => #{self[k].sub_inspect}" }.join(",") + "}"
    184 end

to_xml() click to toggle source

Return an XML string representation of the node. It is shallow, not recursing into subnodes

        # File lib/dbus/bus.rb
    151     def to_xml
    152       xml = '<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN"
    153 "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
    154 <node>
    155 '
    156       each_pair do |k, _v|
    157         xml += "<node name=\"#{k}\" />"
    158       end
    159       if @object
    160         @object.intfs.each_pair do |_k, v|
    161           xml += %(<interface name="#{v.name}">\n)
    162           v.methods.each_value { |m| xml += m.to_xml }
    163           v.signals.each_value { |m| xml += m.to_xml }
    164           xml += "</interface>\n"
    165         end
    166       end
    167       xml += "</node>"
    168       xml
    169     end