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 ⇒ Object
readonly
The name of the node.
-
#object ⇒ Object
The D-Bus object contained by the node.
Instance Method Summary collapse
-
#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 ⇒ Object
Return an XML string representation of the node.
Constructor Details
#initialize(name) ⇒ Node
Create a new node with a given name.
137 138 139 140 |
# File 'lib/dbus/bus.rb', line 137 def initialize(name) @name = name @object = nil end |
Instance Attribute Details
#name ⇒ Object (readonly)
The name of the node.
134 135 136 |
# File 'lib/dbus/bus.rb', line 134 def name @name end |
#object ⇒ Object
The D-Bus object contained by the node.
132 133 134 |
# File 'lib/dbus/bus.rb', line 132 def object @object end |
Instance Method Details
#inspect ⇒ Object
Return inspect information of the node.
165 166 167 168 |
# File 'lib/dbus/bus.rb', line 165 def inspect # Need something here "<DBus::Node #{sub_inspect}>" end |
#sub_inspect ⇒ Object
Return instance inspect information, used by Node#inspect.
171 172 173 174 175 176 177 |
# 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 |
#to_xml ⇒ Object
Return an XML string representation of the node. It is shallow, not recursing into subnodes
144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 |
# 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 |