Module: DInstaller::DBus::Clients::WithProgress

Defined in:
lib/dinstaller/dbus/clients/with_progress.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 Progress interface.

Mixin for clients of services that define the Progress D-Bus interface

Provides methods to interact with the API of the Progress interface.

Instance Method Summary collapse

Instance Method Details

#on_progress_change(&block) {|total_steps, current_step, message, finished| ... } ⇒ Object

Registers a callback to run when the progress changes

Parameters:

  • block (Proc)

Yield Parameters:

  • total_steps (Integer)
  • current_step (Integer)
  • message (String)
  • finished (Boolean)


42
43
44
45
46
47
48
49
50
51
52
# File 'lib/dinstaller/dbus/clients/with_progress.rb', line 42

def on_progress_change(&block)
  on_properties_change(dbus_object) do |interface, changes, _|
    if interface == Interfaces::Progress::PROGRESS_INTERFACE
      total_steps = changes["TotalSteps"]
      current_step = changes["CurrentStep"][0]
      message = changes["CurrentStep"][1]
      finished = changes["Finished"]
      block.call(total_steps, current_step, message, finished)
    end
  end
end