Class: RubyHome::Accessory
- Inherits:
-
Object
- Object
- RubyHome::Accessory
- Defined in:
- lib/ruby_home/hap/accessory.rb
Instance Attribute Summary collapse
-
#id ⇒ Object
Returns the value of attribute id.
-
#services ⇒ Object
readonly
Returns the value of attribute services.
Instance Method Summary collapse
- #characteristics ⇒ Object
-
#initialize ⇒ Accessory
constructor
A new instance of Accessory.
- #instance_ids ⇒ Object
- #largest_instance_id ⇒ Object
- #next_available_instance_id ⇒ Object
Constructor Details
#initialize ⇒ Accessory
Returns a new instance of Accessory.
3 4 5 |
# File 'lib/ruby_home/hap/accessory.rb', line 3 def initialize @services = [] end |
Instance Attribute Details
#id ⇒ Object
Returns the value of attribute id.
7 8 9 |
# File 'lib/ruby_home/hap/accessory.rb', line 7 def id @id end |
#services ⇒ Object (readonly)
Returns the value of attribute services.
7 8 9 |
# File 'lib/ruby_home/hap/accessory.rb', line 7 def services @services end |
Instance Method Details
#characteristics ⇒ Object
10 11 12 |
# File 'lib/ruby_home/hap/accessory.rb', line 10 def characteristics services.flat_map(&:characteristics) end |
#instance_ids ⇒ Object
18 19 20 |
# File 'lib/ruby_home/hap/accessory.rb', line 18 def instance_ids services.map(&:instance_id) + characteristics.map(&:instance_id) end |
#largest_instance_id ⇒ Object
22 23 24 |
# File 'lib/ruby_home/hap/accessory.rb', line 22 def largest_instance_id instance_ids.max end |
#next_available_instance_id ⇒ Object
14 15 16 |
# File 'lib/ruby_home/hap/accessory.rb', line 14 def next_available_instance_id (largest_instance_id || 0) + 1 end |