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.



189
190
191
192
193
194
195
196
197
198
199
200
# File 'lib/dbus/introspect.rb', line 189

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.



203
204
205
206
207
208
209
210
211
# File 'lib/dbus/introspect.rb', line 203

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