Class: DBus::Signal

Inherits:
InterfaceElement show all
Defined in:
lib/dbus/introspect.rb

Overview

D-Bus interface signal class

This is a class representing signals that are part of an interface.

Instance Attribute Summary

Attributes inherited from InterfaceElement

#name, #params

Instance Method Summary collapse

Methods inherited from InterfaceElement

#add_param, #initialize, #validate_name

Constructor Details

This class inherits a constructor from DBus::InterfaceElement

Instance Method Details

#from_prototype(prototype) ⇒ Object

Add parameter types based on the given prototype.



170
171
172
173
174
175
176
177
178
179
180
181
# File 'lib/dbus/introspect.rb', line 170

def from_prototype(prototype)
  prototype.split(/, */).each do |arg|
    if arg =~ /:/
      arg = arg.split(":")
      name, sig = arg
    else
      sig = arg
    end
    add_param([name, sig])
  end
  self
end

#to_xmlObject

Return an XML string representation of the signal interface elment.



184
185
186
187
188
189
190
191
192
# File 'lib/dbus/introspect.rb', line 184

def to_xml
  xml = %{<signal name="#{@name}">\n}
  @params.each do |param|
    name = param[0] ? %{name="#{param[0]}" } : ""
    xml += %{<arg #{name}type="#{param[1]}"/>\n}
  end
  xml += %{</signal>\n}
  xml
end