Class: RubyHome::Accessory

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby_home/hap/accessory.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeAccessory

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

#idObject

Returns the value of attribute id.



7
8
9
# File 'lib/ruby_home/hap/accessory.rb', line 7

def id
  @id
end

#servicesObject (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

#characteristicsObject



10
11
12
# File 'lib/ruby_home/hap/accessory.rb', line 10

def characteristics
  services.flat_map(&:characteristics)
end

#instance_idsObject



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_idObject



22
23
24
# File 'lib/ruby_home/hap/accessory.rb', line 22

def largest_instance_id
  instance_ids.max
end

#next_available_instance_idObject



14
15
16
# File 'lib/ruby_home/hap/accessory.rb', line 14

def next_available_instance_id
  (largest_instance_id || 0) + 1
end