class DBus::Method

D-Bus interface method class

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

Attributes

rets[R]

@return [Array<FormalParameter>] The list of return values for the method

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
185 def initialize(name)
186   super(name)
187   @rets = []
188 end

Public Instance Methods

add_return(name, signature) click to toggle source

Add a return value name and signature. @param name [#to_s] @param signature [SingleCompleteType]

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

Add parameter types by parsing the given prototype. @param prototype [Prototype]

    # File lib/dbus/introspect.rb
199 def from_prototype(prototype)
200   prototype.split(/, */).each do |arg|
201     arg = arg.split(" ")
202     raise InvalidClassDefinition if arg.size != 2
203 
204     dir, arg = arg
205     if arg =~ /:/
206       arg = arg.split(":")
207       name, sig = arg
208     else
209       sig = arg
210     end
211     case dir
212     when "in"
213       add_fparam(name, sig)
214     when "out"
215       add_return(name, sig)
216     end
217   end
218   self
219 end
to_xml() click to toggle source

Return an XML string representation of the method interface elment. @return [String]

    # File lib/dbus/introspect.rb
223 def to_xml
224   xml = "    <method name=\"#{@name}\">\n"
225   @params.each do |param|
226     name = param.name ? "name=\"#{param.name}\" " : ""
227     xml += "      <arg #{name}direction=\"in\" type=\"#{param.type}\"/>\n"
228   end
229   @rets.each do |param|
230     name = param.name ? "name=\"#{param.name}\" " : ""
231     xml += "      <arg #{name}direction=\"out\" type=\"#{param.type}\"/>\n"
232   end
233   xml += "    </method>\n"
234   xml
235 end