Class: DInstaller::DBus::ServiceStatus

Inherits:
Object
  • Object
show all
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

Constructor Details

#initializeServiceStatus

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

#busyself

Note:

Callbacks are called.

Changes the service status value to busy

Returns:

  • (self)


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

Returns:

  • (Boolean)


42
43
44
# File 'lib/dinstaller/dbus/service_status.rb', line 42

def busy?
  value == BUSY
end

#idleself

Note:

Callbacks are called.

Changes the service status value to idle

Returns:

  • (self)


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

Parameters:

  • block (Proc)


69
70
71
# File 'lib/dinstaller/dbus/service_status.rb', line 69

def on_change(&block)
  @on_change_callbacks << block
end