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
136 def initialize(name)
137   super(name)
138   @rets = []
139 end

Public Instance Methods

add_return(name, signature) click to toggle source

Add a return value name and signature.

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

Add parameter types by parsing the given prototype.

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

Return an XML string representation of the method interface elment.

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