class DBus::Method

D-Bus interface method class ↑

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

Attributes

rets[R]

The list of return values for the method. Array: FormalParameter

Public Class Methods

new(name) click to toggle source

Creates a new method interface element with the given name.

Calls superclass method DBus::InterfaceElement::new
    # File lib/dbus/introspect.rb
140 def initialize(name)
141   super(name)
142   @rets = []
143 end

Public Instance Methods

add_return(name, signature) click to toggle source

Add a return value name and signature.

    # File lib/dbus/introspect.rb
146 def add_return(name, signature)
147   @rets << FormalParameter.new(name, signature)
148 end
from_prototype(prototype) click to toggle source

Add parameter types by parsing the given prototype.

    # File lib/dbus/introspect.rb
151 def from_prototype(prototype)
152   prototype.split(/, */).each do |arg|
153     arg = arg.split(" ")
154     raise InvalidClassDefinition if arg.size != 2
155     dir, arg = arg
156     if arg =~ /:/
157       arg = arg.split(":")
158       name, sig = arg
159     else
160       sig = arg
161     end
162     case dir
163     when "in"
164       add_fparam(name, sig)
165     when "out"
166       add_return(name, sig)
167     end
168   end
169   self
170 end
to_xml() click to toggle source

Return an XML string representation of the method interface elment.

    # File lib/dbus/introspect.rb
173 def to_xml
174   xml = %(<method name="#{@name}">\n)
175   @params.each do |param|
176     name = param.name ? %(name="#{param.name}" ) : ""
177     xml += %(<arg #{name}direction="in" type="#{param.type}"/>\n)
178   end
179   @rets.each do |param|
180     name = param.name ? %(name="#{param.name}" ) : ""
181     xml += %(<arg #{name}direction="out" type="#{param.type}"/>\n)
182   end
183   xml += %(</method>\n)
184   xml
185 end