Module: DInstaller::DBus::Clients::WithServiceStatus
- Defined in:
- lib/dinstaller/dbus/clients/with_service_status.rb
Overview
Note:
This mixin is expected to be included in a class inherited from Base and it requires a #dbus_object method that returns a DBus::Object implementing the ServiceStatus interface.
Mixin for clients of services that define the ServiceStatus D-Bus interface
Provides methods to interact with the API of the ServiceStatus interface.
Instance Method Summary collapse
-
#on_service_status_change(&block) {|service_status| ... } ⇒ Object
Registers a callback to run when the current status property changes.
-
#service_status ⇒ ServiceStatus::IDLE, ServiceStatus::BUSY
Current value of the service status.
-
#to_service_status(dbus_status) ⇒ ServiceStatus::IDLE, ServiceStatus::BUSY
Converts the D-Bus status value to the equivalent service status value.
Instance Method Details
#on_service_status_change(&block) {|service_status| ... } ⇒ Object
Registers a callback to run when the current status property changes
51 52 53 54 55 56 57 58 |
# File 'lib/dinstaller/dbus/clients/with_service_status.rb', line 51 def on_service_status_change(&block) on_properties_change(dbus_object) do |interface, changes, _| if interface == Interfaces::ServiceStatus::SERVICE_STATUS_INTERFACE service_status = to_service_status(changes["Current"]) block.call(service_status) end end end |
#service_status ⇒ ServiceStatus::IDLE, ServiceStatus::BUSY
Current value of the service status
42 43 44 45 |
# File 'lib/dinstaller/dbus/clients/with_service_status.rb', line 42 def service_status dbus_status = dbus_object[Interfaces::ServiceStatus::SERVICE_STATUS_INTERFACE]["Current"] to_service_status(dbus_status) end |
#to_service_status(dbus_status) ⇒ ServiceStatus::IDLE, ServiceStatus::BUSY
Converts the D-Bus status value to the equivalent service status value
64 65 66 67 68 69 70 71 |
# File 'lib/dinstaller/dbus/clients/with_service_status.rb', line 64 def to_service_status(dbus_status) case dbus_status when Interfaces::ServiceStatus::SERVICE_STATUS_IDLE ServiceStatus::IDLE when Interfaces::ServiceStatus::SERVICE_STATUS_BUSY ServiceStatus::BUSY end end |