Class: DBus::RemoteObject
- Inherits:
-
Object
- Object
- DBus::RemoteObject
- Defined in:
- lib/dbus.rb
Overview
Represents a remote object.
A RemoteObject is provided by a RemoteService on a particular Bus. RemoteObjects have member functions, and can be called like normal Ruby objects.
Instance Method Summary collapse
-
#connect_to_signal(signal_name, handler_proc) ⇒ Object
Connect the signal
signal_name
on this remote object to the supplied handler prochandler_proc
. -
#initialize(service, object_path, interface) ⇒ RemoteObject
constructor
A new instance of RemoteObject.
-
#method_missing(sym, *args) ⇒ Object
Implements magic remote method calls.
Constructor Details
#initialize(service, object_path, interface) ⇒ RemoteObject
Returns a new instance of RemoteObject.
153 154 155 156 157 |
# File 'lib/dbus.rb', line 153 def initialize(service, object_path, interface) @service = service @object_path = object_path @interface = interface end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(sym, *args) ⇒ Object
Implements magic remote method calls
170 171 172 173 174 175 176 177 178 179 180 181 182 183 |
# File 'lib/dbus.rb', line 170 def method_missing(sym, *args) name = sym.id2name = DBus::Binding::DBusMessage.new_method_call(@service.get_service_name, @object_path, @interface, name) iter = .get_iter args.each{|a| iter.append(a)} reply = @service.get_bus.get_connection.send_with_reply_and_block(, 5000) reply_args = reply.to_a return nil if reply_args.empty? return reply_args[0] if reply_args.length == 1 return reply_args end |
Instance Method Details
#connect_to_signal(signal_name, handler_proc) ⇒ Object
Connect the signal signal_name
on this remote object to the supplied handler proc handler_proc
.
161 162 163 164 165 166 167 |
# File 'lib/dbus.rb', line 161 def connect_to_signal(signal_name, handler_proc) @service.get_bus.add_signal_receiver(handler_proc, signal_name, @interface, @service.get_service_name, @object_path) end |