Class: RubyHome::Characteristic
- Inherits:
-
Object
- Object
- RubyHome::Characteristic
- Includes:
- Wisper::Publisher
- Defined in:
- lib/ruby_home/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
- #accessory ⇒ Object
- #accessory_id ⇒ Object
- #after_update(&block) ⇒ Object
-
#initialize(uuid:, name:, description:, format:, unit:, properties:, service:, value_object:) ⇒ Characteristic
constructor
A new instance of Characteristic.
- #method_missing(method_name, *args, &block) ⇒ Object
- #respond_to_missing?(method_name, *args) ⇒ Boolean
- #service_iid ⇒ Object
- #unsubscribe(*listeners) ⇒ Object
- #value ⇒ Object
- #value=(new_value) ⇒ Object
Constructor Details
#initialize(uuid:, name:, description:, format:, unit:, properties:, service:, value_object:) ⇒ Characteristic
Returns a new instance of Characteristic.
28 29 30 31 32 33 34 35 36 37 |
# File 'lib/ruby_home/characteristic.rb', line 28 def initialize(uuid:, name:, description:, format:, unit:, properties:, service: , value_object: ) @uuid = uuid @name = name @description = description @format = format @unit = unit @properties = properties @service = service @value_object = value_object end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *args, &block) ⇒ Object
69 70 71 |
# File 'lib/ruby_home/characteristic.rb', line 69 def method_missing(method_name, *args, &block) value.send(method_name, *args, &block) end |
Instance Attribute Details
#description ⇒ Object (readonly)
Returns the value of attribute description.
39 40 41 |
# File 'lib/ruby_home/characteristic.rb', line 39 def description @description end |
#format ⇒ Object (readonly)
Returns the value of attribute format.
39 40 41 |
# File 'lib/ruby_home/characteristic.rb', line 39 def format @format end |
#instance_id ⇒ Object
Returns the value of attribute instance_id.
39 40 41 |
# File 'lib/ruby_home/characteristic.rb', line 39 def instance_id @instance_id end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
39 40 41 |
# File 'lib/ruby_home/characteristic.rb', line 39 def name @name end |
#properties ⇒ Object (readonly)
Returns the value of attribute properties.
39 40 41 |
# File 'lib/ruby_home/characteristic.rb', line 39 def properties @properties end |
#service ⇒ Object (readonly)
Returns the value of attribute service.
39 40 41 |
# File 'lib/ruby_home/characteristic.rb', line 39 def service @service end |
#unit ⇒ Object (readonly)
Returns the value of attribute unit.
39 40 41 |
# File 'lib/ruby_home/characteristic.rb', line 39 def unit @unit end |
#uuid ⇒ Object (readonly)
Returns the value of attribute uuid.
39 40 41 |
# File 'lib/ruby_home/characteristic.rb', line 39 def uuid @uuid end |
Instance Method Details
#accessory ⇒ Object
57 58 59 |
# File 'lib/ruby_home/characteristic.rb', line 57 def accessory service.accessory end |
#accessory_id ⇒ Object
61 62 63 |
# File 'lib/ruby_home/characteristic.rb', line 61 def accessory_id accessory.id end |
#after_update(&block) ⇒ Object
17 18 19 |
# File 'lib/ruby_home/characteristic.rb', line 17 def after_update(&block) on(:after_update, &block) end |
#respond_to_missing?(method_name, *args) ⇒ Boolean
73 74 75 |
# File 'lib/ruby_home/characteristic.rb', line 73 def respond_to_missing?(method_name, *args) value.respond_to?(method_name, *args) || super end |
#service_iid ⇒ Object
65 66 67 |
# File 'lib/ruby_home/characteristic.rb', line 65 def service_iid service.instance_id end |
#unsubscribe(*listeners) ⇒ Object
11 12 13 14 15 |
# File 'lib/ruby_home/characteristic.rb', line 11 def unsubscribe(*listeners) local_registrations.delete_if do |registration| listeners.include?(registration.listener) end end |
#value ⇒ Object
77 78 79 |
# File 'lib/ruby_home/characteristic.rb', line 77 def value value_object.value end |
#value=(new_value) ⇒ Object
81 82 83 84 |
# File 'lib/ruby_home/characteristic.rb', line 81 def value=(new_value) value_object.value = new_value broadcast(:after_update, value) end |