Class: SystemdMon::DBusUnit
- Inherits:
-
Object
- Object
- SystemdMon::DBusUnit
- Defined in:
- lib/systemd_mon/dbus_unit.rb
Constant Summary collapse
- IFACE_UNIT =
"org.freedesktop.systemd1.Unit"- IFACE_SERVICE =
"org.freedesktop.systemd1.Service"- IFACE_PROPS =
"org.freedesktop.DBus.Properties"
Instance Attribute Summary collapse
-
#maybe_service_type ⇒ Object
readonly
Returns the value of attribute maybe_service_type.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
-
#initialize(name, path, dbus_object) ⇒ DBusUnit
constructor
A new instance of DBusUnit.
- #on_change(&callback) ⇒ Object
- #on_each_state_change(&callback) ⇒ Object
- #property(name) ⇒ Object
- #register_listener!(queue) ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(name, path, dbus_object) ⇒ DBusUnit
Returns a new instance of DBusUnit.
11 12 13 14 15 16 17 |
# File 'lib/systemd_mon/dbus_unit.rb', line 11 def initialize(name, path, dbus_object) self.name = name self.path = path self.dbus_object = dbus_object prepare_dbus_objects! self.maybe_service_type = service_type end |
Instance Attribute Details
#maybe_service_type ⇒ Object
Returns the value of attribute maybe_service_type.
5 6 7 |
# File 'lib/systemd_mon/dbus_unit.rb', line 5 def maybe_service_type @maybe_service_type end |
#name ⇒ Object
Returns the value of attribute name.
5 6 7 |
# File 'lib/systemd_mon/dbus_unit.rb', line 5 def name @name end |
Instance Method Details
#on_change(&callback) ⇒ Object
28 29 30 |
# File 'lib/systemd_mon/dbus_unit.rb', line 28 def on_change(&callback) self.change_callback = callback end |
#on_each_state_change(&callback) ⇒ Object
32 33 34 |
# File 'lib/systemd_mon/dbus_unit.rb', line 32 def on_each_state_change(&callback) self.each_state_change_callback = callback end |
#property(name) ⇒ Object
36 37 38 |
# File 'lib/systemd_mon/dbus_unit.rb', line 36 def property(name) dbus_object.Get(IFACE_UNIT, name).first end |
#register_listener!(queue) ⇒ Object
19 20 21 22 23 24 25 26 |
# File 'lib/systemd_mon/dbus_unit.rb', line 19 def register_listener!(queue) queue.enq [self, build_state] # initial state dbus_object.on_signal("PropertiesChanged") do |iface| if iface == IFACE_UNIT queue.enq [self, build_state] end end end |
#to_s ⇒ Object
40 41 42 |
# File 'lib/systemd_mon/dbus_unit.rb', line 40 def to_s "#{name}" << (maybe_service_type ? " (#{maybe_service_type})" : '') end |