Class: DBus::Systemd::Importd::Manager
- Inherits:
-
Object
- Object
- DBus::Systemd::Importd::Manager
- Includes:
- Mixin::MethodMissing, Mixin::Properties
- Defined in:
- lib/dbus/systemd/importd/manager.rb
Constant Summary collapse
- NODE =
the importd manager dbus node path
'/org/freedesktop/import1'.freeze
- INTERFACE =
the importd manager dbus interface
'org.freedesktop.import1.Manager'.freeze
- TRANSFER_INDICES =
index mapping of transfer array returned from ListTransfers()
{ id: 0, operation: 1, remote_file: 2, image_name: 3, progress: 4, object_path: 5 }.freeze
Instance Attribute Summary collapse
- #service ⇒ DBus::Service readonly private
Attributes included from Mixin::MethodMissing
Instance Method Summary collapse
-
#get_transfer_by_path(path) ⇒ DBus::Systemd::Importd::Transfer
Create a transfer object from the transfer node path.
-
#initialize(bus = Systemd::Helpers.system_bus) ⇒ Manager
constructor
Creates a new Manager object for interfacing with the hostnamed Manager interface.
-
#map_transfer(transfer_array) ⇒ Hash
map a transfer array as returned from ListTransfers to a hash with keys from TRANSER_INDICES.
-
#transfer(id) ⇒ DBus::Systemd::Importd::Transfer
Create a transfer object from a transfer id.
-
#transfers ⇒ Array
return a list of mapped transfers.
Methods included from Mixin::Properties
Methods included from Mixin::MethodMissing
#method_missing, #respond_to_missing?
Constructor Details
#initialize(bus = Systemd::Helpers.system_bus) ⇒ Manager
Creates a new Manager object for interfacing with the hostnamed Manager interface
60 61 62 63 64 65 |
# File 'lib/dbus/systemd/importd/manager.rb', line 60 def initialize(bus = Systemd::Helpers.system_bus) @service = bus.service(Importd::SERVICE) @object = @service.object(NODE) @object.default_iface = INTERFACE @object.introspect end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class DBus::Systemd::Mixin::MethodMissing
Instance Attribute Details
#service ⇒ DBus::Service (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
53 54 55 |
# File 'lib/dbus/systemd/importd/manager.rb', line 53 def service @service end |
Instance Method Details
#get_transfer_by_path(path) ⇒ DBus::Systemd::Importd::Transfer
Create a transfer object from the transfer node path
89 90 91 92 93 |
# File 'lib/dbus/systemd/importd/manager.rb', line 89 def get_transfer_by_path(path) obj = @service.object(path) .tap(&:introspect) Transfer.new(obj.Get(Transfer::INTERFACE, 'Id').first, self) end |
#map_transfer(transfer_array) ⇒ Hash
map a transfer array as returned from ListTransfers to a hash with keys from TRANSER_INDICES
101 102 103 |
# File 'lib/dbus/systemd/importd/manager.rb', line 101 def map_transfer(transfer_array) Systemd::Helpers.map_array(transfer_array, TRANSFER_INDICES) end |
#transfer(id) ⇒ DBus::Systemd::Importd::Transfer
Create a transfer object from a transfer id
80 81 82 |
# File 'lib/dbus/systemd/importd/manager.rb', line 80 def transfer(id) Transfer.new(id, self) end |
#transfers ⇒ Array
return a list of mapped transfers
71 72 73 |
# File 'lib/dbus/systemd/importd/manager.rb', line 71 def transfers self.ListTransfers.first.map { |t| map_transfer(t) } end |