Module: DBus::Systemd::Helpers

Defined in:
lib/dbus/systemd/helpers.rb

Class Method Summary collapse

Class Method Details

.map_array(array, map) ⇒ Hash

map an array to a hash from an index map

Parameters:

  • array (Array)

    array to be mapped

  • map (Hash)

    map of positional elements to array indices

Returns:

  • (Hash)

    hash with keys from map and values from array



48
49
50
51
52
53
54
55
56
# File 'lib/dbus/systemd/helpers.rb', line 48

def map_array(array, map)
  mapped = {}

  array.each_with_index do |item, index|
    mapped[map.key(index)] = item
  end

  mapped
end

.session_busDBus::SessionBus

get an instance of the session bus

Returns:

  • (DBus::SessionBus)


38
39
40
# File 'lib/dbus/systemd/helpers.rb', line 38

def session_bus
  DBus::SessionBus.instance
end

.system_busDBus::SystemBus

get an instance of the system bus

Returns:

  • (DBus::SystemBus)


30
31
32
# File 'lib/dbus/systemd/helpers.rb', line 30

def system_bus
  DBus::SystemBus.instance
end