Class: RubyHome::Characteristic
- Inherits:
-
Object
- Object
- RubyHome::Characteristic
- Includes:
- Wisper::Publisher
- Defined in:
- lib/ruby_home/hap/characteristic.rb
Constant Summary collapse
- PROPERTIES =
{ 'cnotify' => 'ev', 'read' => 'pr', 'uncnotify' => nil, 'write' => 'pw', }.freeze
Instance Attribute Summary collapse
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#format ⇒ Object
readonly
Returns the value of attribute format.
-
#instance_id ⇒ Object
Returns the value of attribute instance_id.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#properties ⇒ Object
readonly
Returns the value of attribute properties.
-
#service ⇒ Object
readonly
Returns the value of attribute service.
-
#unit ⇒ Object
readonly
Returns the value of attribute unit.
-
#uuid ⇒ Object
readonly
Returns the value of attribute uuid.
Instance Method Summary collapse
- #after_update(&block) ⇒ Object
-
#initialize(uuid:, name:, description:, format:, unit:, properties:, service:, value: nil) ⇒ Characteristic
constructor
A new instance of Characteristic.
- #service_iid ⇒ Object
- #unsubscribe(*listeners) ⇒ Object
- #value ⇒ Object
- #value=(new_value) ⇒ Object
Constructor Details
#initialize(uuid:, name:, description:, format:, unit:, properties:, service:, value: nil) ⇒ Characteristic
Returns a new instance of Characteristic.
26 27 28 29 30 31 32 33 34 35 |
# File 'lib/ruby_home/hap/characteristic.rb', line 26 def initialize(uuid:, name:, description:, format:, unit:, properties:, service: , value: nil) @uuid = uuid @name = name @description = description @format = format @unit = unit @properties = properties @service = service @value = value end |
Instance Attribute Details
#description ⇒ Object (readonly)
Returns the value of attribute description.
37 38 39 |
# File 'lib/ruby_home/hap/characteristic.rb', line 37 def description @description end |
#format ⇒ Object (readonly)
Returns the value of attribute format.
37 38 39 |
# File 'lib/ruby_home/hap/characteristic.rb', line 37 def format @format end |
#instance_id ⇒ Object
Returns the value of attribute instance_id.
37 38 39 |
# File 'lib/ruby_home/hap/characteristic.rb', line 37 def instance_id @instance_id end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
37 38 39 |
# File 'lib/ruby_home/hap/characteristic.rb', line 37 def name @name end |
#properties ⇒ Object (readonly)
Returns the value of attribute properties.
37 38 39 |
# File 'lib/ruby_home/hap/characteristic.rb', line 37 def properties @properties end |
#service ⇒ Object (readonly)
Returns the value of attribute service.
37 38 39 |
# File 'lib/ruby_home/hap/characteristic.rb', line 37 def service @service end |
#unit ⇒ Object (readonly)
Returns the value of attribute unit.
37 38 39 |
# File 'lib/ruby_home/hap/characteristic.rb', line 37 def unit @unit end |
#uuid ⇒ Object (readonly)
Returns the value of attribute uuid.
37 38 39 |
# File 'lib/ruby_home/hap/characteristic.rb', line 37 def uuid @uuid end |
Instance Method Details
#after_update(&block) ⇒ Object
15 16 17 |
# File 'lib/ruby_home/hap/characteristic.rb', line 15 def after_update(&block) on(:after_update, &block) end |
#service_iid ⇒ Object
57 58 59 |
# File 'lib/ruby_home/hap/characteristic.rb', line 57 def service_iid service.instance_id end |
#unsubscribe(*listeners) ⇒ Object
9 10 11 12 13 |
# File 'lib/ruby_home/hap/characteristic.rb', line 9 def unsubscribe(*listeners) local_registrations.delete_if do |registration| listeners.include?(registration.listener) end end |
#value ⇒ Object
61 62 63 |
# File 'lib/ruby_home/hap/characteristic.rb', line 61 def value @value.value end |
#value=(new_value) ⇒ Object
65 66 67 68 |
# File 'lib/ruby_home/hap/characteristic.rb', line 65 def value=(new_value) @value.value = new_value broadcast(:after_update, self) end |