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.



118
119
120
121
122
# File 'lib/dbus/introspect.rb', line 118

def initialize(name)
  validate_name(name.to_s)
  @name = name
  @params = Array.new
end

Instance Attribute Details

#nameObject (readonly)

The name of the interface element. Symbol



106
107
108
# File 'lib/dbus/introspect.rb', line 106

def name
  @name
end

#paramsObject (readonly)

The parameters of the interface element. Array: FormalParameter



108
109
110
# File 'lib/dbus/introspect.rb', line 108

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)



126
127
128
# File 'lib/dbus/introspect.rb', line 126

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

#add_param(name_signature_pair) ⇒ Object

Deprecated, for backward compatibility



131
132
133
# File 'lib/dbus/introspect.rb', line 131

def add_param(name_signature_pair)
  add_fparam(*name_signature_pair)
end

#validate_name(name) ⇒ Object

Validates element name.



111
112
113
114
115
# File 'lib/dbus/introspect.rb', line 111

def validate_name(name)
  if (not name =~ MethodSignalRE) or (name.bytesize > 255)
    raise InvalidMethodName, name
  end
end