Class: DBus::EmitsChangedSignal

Inherits:
Object
  • Object
show all
Defined in:
lib/dbus/emits_changed_signal.rb

Overview

Describes the behavior of PropertiesChanged signal, for a single property or for an entire interface.

The possible values are:

  • true: the signal is emitted with the value included.

  • :invalidates: the signal is emitted but the value is not included in the signal.

  • :const: the property never changes value during the lifetime of the object it belongs to, and hence the signal is never emitted for it (but clients can cache the value)

  • false: the signal won’t be emitted (clients should re-Get the property value)

The default is:

  • for an interface: true

  • for a property: what the parent interface specifies

Immutable once constructed.

Constant Summary collapse

DEFAULT_ECS =
EmitsChangedSignal.new(true)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(value, interface: nil) ⇒ EmitsChangedSignal

Returns a new instance of EmitsChangedSignal.

Parameters:

  • value (true, false, :const, :invalidates, nil)

    See class-level description above, DBus::EmitsChangedSignal.

  • interface (Interface, nil) (defaults to: nil)

    If the (property-level) value is unspecified (nil), this is the containing Interface to get the value from.



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/dbus/emits_changed_signal.rb', line 43

def initialize(value, interface: nil)
  if value.nil?
    raise ArgumentError, "Both arguments are nil" if interface.nil?

    @value = interface.emits_changed_signal.value
  else
    expecting = [true, false, :const, :invalidates]
    unless expecting.include?(value)
      raise ArgumentError, "Expecting one of #{expecting.inspect}. Seen #{value.inspect}"
    end

    @value = value
  end

  freeze
end

Instance Attribute Details

#valuetrue, ... (readonly)

Returns:

  • (true, false, :const, :invalidates)


36
37
38
# File 'lib/dbus/emits_changed_signal.rb', line 36

def value
  @value
end

Instance Method Details

#==(other) ⇒ Object Also known as: eql?



72
73
74
75
76
77
78
# File 'lib/dbus/emits_changed_signal.rb', line 72

def ==(other)
  if other.is_a?(self.class)
    other.value == @value
  else
    other == value
  end
end

#to_sObject



68
69
70
# File 'lib/dbus/emits_changed_signal.rb', line 68

def to_s
  @value.to_s
end

#to_xmlString

Return introspection XML string representation

Returns:

  • (String)


62
63
64
65
66
# File 'lib/dbus/emits_changed_signal.rb', line 62

def to_xml
  return "" if @value == true

  "    <annotation name=\"org.freedesktop.DBus.Property.EmitsChangedSignal\" value=\"#{@value}\"/>\n"
end