Class DBus::Node
In: lib/dbus/bus.rb
Parent: Hash

Object path node class

Class representing a node on an object path.

Methods

inspect   new   sub_inspect   to_xml  

Attributes

name  [R]  The name of the node.
object  [RW]  The D-Bus object contained by the node.

Public Class methods

Create a new node with a given name.

[Source]

# File lib/dbus/bus.rb, line 137
    def initialize(name)
      @name = name
      @object = nil
    end

Public Instance methods

Return inspect information of the node.

[Source]

# File lib/dbus/bus.rb, line 165
    def inspect
      # Need something here
      "<DBus::Node #{sub_inspect}>"
    end

Return instance inspect information, used by Node#inspect.

[Source]

# File lib/dbus/bus.rb, line 171
    def sub_inspect
      s = ""
      if not @object.nil?
        s += "%x " % @object.object_id
      end
      s + "{" + keys.collect { |k| "#{k} => #{self[k].sub_inspect}" }.join(",") + "}"
    end

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

[Source]

# File lib/dbus/bus.rb, line 144
    def to_xml
      xml = '<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN"
"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
<node>
'
      self.each_pair do |k, v|
        xml += "<node name=\"#{k}\" />"
      end
      if @object
        @object.intfs.each_pair do |k, v|
          xml += %{<interface name="#{v.name}">\n}
          v.methods.each_value { |m| xml += m.to_xml }
          v.signals.each_value { |m| xml += m.to_xml }
          xml +="</interface>\n"
        end
      end
      xml += '</node>'
      xml
    end

[Validate]