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_fparam, #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.



243
244
245
246
247
248
249
250
251
252
253
254
# File 'lib/dbus/introspect.rb', line 243

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

#to_xmlObject

Return an XML string representation of the signal interface elment.



257
258
259
260
261
262
263
264
265
# File 'lib/dbus/introspect.rb', line 257

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