Class: DInstaller::DBus::ServiceStatus
- Inherits:
-
Object
- Object
- DInstaller::DBus::ServiceStatus
- Defined in:
- lib/dinstaller/dbus/service_status.rb
Overview
Represents the status of a D-Installer service and allows to configure callbacks to be called when the status value changes
Constant Summary collapse
- IDLE =
Possible values of the service status
"idle"
- BUSY =
"busy"
Instance Method Summary collapse
-
#busy ⇒ self
Changes the service status value to busy.
-
#busy? ⇒ Boolean
Whether the current service status value is busy.
-
#idle ⇒ self
Changes the service status value to idle.
-
#initialize ⇒ ServiceStatus
constructor
Constructor.
-
#on_change(&block) ⇒ Object
Registers a callback to be called when the service status changes.
Constructor Details
#initialize ⇒ ServiceStatus
Constructor
The service status is initialized as idle.
34 35 36 37 |
# File 'lib/dinstaller/dbus/service_status.rb', line 34 def initialize @value = IDLE @on_change_callbacks = [] end |
Instance Method Details
#busy ⇒ self
Note:
Callbacks are called.
Changes the service status value to busy
61 62 63 64 |
# File 'lib/dinstaller/dbus/service_status.rb', line 61 def busy change_to(BUSY) self end |
#busy? ⇒ Boolean
Whether the current service status value is busy
42 43 44 |
# File 'lib/dinstaller/dbus/service_status.rb', line 42 def busy? value == BUSY end |
#idle ⇒ self
Note:
Callbacks are called.
Changes the service status value to idle
51 52 53 54 |
# File 'lib/dinstaller/dbus/service_status.rb', line 51 def idle change_to(IDLE) self end |
#on_change(&block) ⇒ Object
Registers a callback to be called when the service status changes
69 70 71 |
# File 'lib/dinstaller/dbus/service_status.rb', line 69 def on_change(&block) @on_change_callbacks << block end |