### Home Classes Methods

### In Files

- lib/dbus/introspect.rb

### Parent

DBus::InterfaceElement

### Methods

- ::new
- #add_return
- #from_prototype
- #to_xml

### Files

- README

### Class/Module Index

Quicksearch

- DBus
- DBus::ASessionBus
- DBus::ASystemBus
- DBus::AuthenticationFailed
- DBus::Authenticator
- DBus::Client
- DBus::Connection
- DBus::Connection::NameRequestError
- DBus::DBusCookieSHA1
- DBus::Error
- DBus::ErrorMessage
- DBus::External
- DBus::FormalParameter
- DBus::IncompleteBufferException
- DBus::Interface
- DBus::InterfaceElement
- DBus::IntrospectXMLParser
- DBus::InvalidClassDefinition
- DBus::InvalidDestinationName
- DBus::InvalidIntrospectionData
- DBus::InvalidMethodName
- DBus::InvalidPacketException
- DBus::InvalidParameters
- DBus::Main
- DBus::MatchRule
- DBus::MatchRuleException
- DBus::Message
- DBus::Method
- DBus::MethodNotImplemented
- DBus::MethodReturnMessage
- DBus::Node
- DBus::Object
- DBus::Object::UndefinedInterface
- DBus::PacketMarshaller
- DBus::PacketUnmarshaller
- DBus::ProxyObject
- DBus::ProxyObjectFactory
- DBus::ProxyObjectInterface
- DBus::RemoteBus
- DBus::Service
- DBus::SessionBus
- DBus::Signal
- DBus::SystemBus
- DBus::Type
- DBus::Type::Parser
- DBus::Type::SignatureException
- DBus::Type::Type
- DBus::TypeException
- DBus::UnknownSignal
- Integer

No matching classes.

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

    # File lib/dbus/introspect.rb, line 144
    def initialize(name)
      super(name)
      @rets = Array.new
    end

### Public Instance Methods

add_return(name, signature) click to toggle source

Add a return value name and signature.

    # File lib/dbus/introspect.rb, line 150
    def add_return(name, signature)
      @rets << FormalParameter.new(name, signature)
    end

from_prototype(prototype) click to toggle source

Add parameter types by parsing the given prototype.

    # File lib/dbus/introspect.rb, line 155
    def from_prototype(prototype)
      prototype.split(/, */).each do |arg|
        arg = arg.split(" ")
        raise InvalidClassDefinition if arg.size != 2
        dir, arg = arg
        if arg =~ /:/
          arg = arg.split(":")
          name, sig = arg
        else
          sig = arg
        end
        case dir
        when "in"
          add_fparam(name, sig)
        when "out"
          add_return(name, sig)
        end
      end
      self
    end

to_xml() click to toggle source

Return an XML string representation of the method interface elment.

    # File lib/dbus/introspect.rb, line 177
    def to_xml
      xml = %{<method name="#{@name}">\n}
      @params.each do |param|
        name = param.name ? %{name="#{param.name}" } : ""
        xml += %{<arg #{name}direction="in" type="#{param.type}"/>\n}
      end
      @rets.each do |param|
        name = param.name ? %{name="#{param.name}" } : ""
        xml += %{<arg #{name}direction="out" type="#{param.type}"/>\n}
      end
      xml += %{</method>\n}
      xml
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.