Class: DBus::IntrospectXMLParser
- Inherits:
-
Object
- Object
- DBus::IntrospectXMLParser
- Defined in:
- lib/dbus/xml.rb
Overview
D-Bus introspect XML parser class
This class parses introspection XML of an object and constructs a tree of Node, Interface, Method, Signal instances.
Defined Under Namespace
Classes: AbstractXML, NokogiriParser, REXMLParser
Class Attribute Summary collapse
-
.backend ⇒ Object
Returns the value of attribute backend.
Instance Method Summary collapse
-
#initialize(xml) ⇒ IntrospectXMLParser
constructor
Creates a new parser for XML data in string xml.
-
#parse ⇒ Object
return a pair: [list of Interfaces, list of direct subnode names].
Constructor Details
#initialize(xml) ⇒ IntrospectXMLParser
Creates a new parser for XML data in string xml.
29 30 31 |
# File 'lib/dbus/xml.rb', line 29 def initialize(xml) @xml = xml end |
Class Attribute Details
.backend ⇒ Object
Returns the value of attribute backend.
26 27 28 |
# File 'lib/dbus/xml.rb', line 26 def backend @backend end |
Instance Method Details
#parse ⇒ Object
return a pair: [list of Interfaces, list of direct subnode names]
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 |
# File 'lib/dbus/xml.rb', line 99 def parse interfaces = Array.new subnodes = Array.new t = Time.now d = IntrospectXMLParser.backend.new(@xml) d.each("node/node") do |e| subnodes << e["name"] end d.each("node/interface") do |e| i = Interface.new(e["name"]) e.each("method") do |me| m = Method.new(me["name"]) parse_methsig(me, m) i << m end e.each("signal") do |se| s = Signal.new(se["name"]) parse_methsig(se, s) i << s end interfaces << i end d = Time.now - t if d > 2 puts "Some XML took more that two secs to parse. Optimize me!" if $DEBUG end [interfaces, subnodes] end |