Class: DBus::InterfaceElement

Inherits:
Object
  • Object
show all
Defined in:
lib/dbus/introspect.rb

Overview

D-Bus interface element class

This is a generic class for entities that are part of the interface such as methods and signals.

Direct Known Subclasses

Method, Signal

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ InterfaceElement

Creates a new element with the given name.



159
160
161
162
163
# File 'lib/dbus/introspect.rb', line 159

def initialize(name)
  validate_name(name.to_s)
  @name = name
  @params = []
end

Instance Attribute Details

#nameSymbol (readonly)

Returns The name of the interface element.

Returns:

  • (Symbol)

    The name of the interface element



146
147
148
# File 'lib/dbus/introspect.rb', line 146

def name
  @name
end

#paramsArray<FormalParameter> (readonly)

Returns The parameters of the interface element.

Returns:



149
150
151
# File 'lib/dbus/introspect.rb', line 149

def params
  @params
end

Instance Method Details

#add_fparam(name, signature) ⇒ Object

Adds a formal parameter with name and signature (See also Message#add_param which takes signature+value)



167
168
169
# File 'lib/dbus/introspect.rb', line 167

def add_fparam(name, signature)
  @params << FormalParameter.new(name, signature)
end

#add_param(name_signature_pair) ⇒ Object

Deprecated, for backward compatibility



172
173
174
# File 'lib/dbus/introspect.rb', line 172

def add_param(name_signature_pair)
  add_fparam(*name_signature_pair)
end

#validate_name(name) ⇒ Object

Validates element name.

Raises:



152
153
154
155
156
# File 'lib/dbus/introspect.rb', line 152

def validate_name(name)
  return if (name =~ METHOD_SIGNAL_RE) && (name.bytesize <= 255)

  raise InvalidMethodName, name
end