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, line 144
def initialize(name)
  @name = name
  @object = nil
end

Public Instance Methods

inspect() click to toggle source

Return inspect information of the node.

# File lib/dbus/bus.rb, line 172
def inspect
  # Need something here
  "<DBus::Node #{sub_inspect}>"
end
sub_inspect() click to toggle source

Return instance inspect information, used by #inspect.

# File lib/dbus/bus.rb, line 178
def sub_inspect
  s = ""
  if !@object.nil?
    s += format("%x ", @object.object_id)
  end
  s + "{" + keys.collect { |k| "#{k} => #{self[k].sub_inspect}" }.join(",") + "}"
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, line 151
    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>
'
      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