class DBus::Systemd::Importd::Manager

Constants

INTERFACE

the importd manager dbus interface

NODE

the importd manager dbus node path

TRANSFER_INDICES

index mapping of transfer array returned from ListTransfers()

Attributes

service[R]

@return [DBus::Service] @api private

Public Class Methods

new(bus = Systemd::Helpers.system_bus) click to toggle source

Creates a new Manager object for interfacing with the hostnamed Manager interface

@param bus [DBus::SystemBus, DBus::SessionBus] dbus instance

# 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

Public Instance Methods

get_transfer_by_path(path) click to toggle source

Create a transfer object from the transfer node path

@param path [String] transfer dbus node path @return [DBus::Systemd::Importd::Transfer] importd transfer object

# 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) click to toggle source

map a transfer array as returned from ListTransfers to a hash with keys from TRANSER_INDICES

@param transfer_array [Array] a transfer array @return [Hash] mapped transfer array to named fields

# 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) click to toggle source

Create a transfer object from a transfer id

@param id [Integer] transfer id @return [DBus::Systemd::Importd::Transfer] importd transfer object

# File lib/dbus/systemd/importd/manager.rb, line 80
def transfer(id)
  Transfer.new(id, self)
end
transfers() click to toggle source

return a list of mapped transfers

@return [Array] array of hashes with transfer data

# File lib/dbus/systemd/importd/manager.rb, line 71
def transfers
  self.ListTransfers.first.map { |t| map_transfer(t) }
end