Class: RubyHome::AccessoryFactory

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby_home/factories/accessory_factory.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(service_name, accessory_options, characteristic_options) ⇒ AccessoryFactory

Returns a new instance of AccessoryFactory.



12
13
14
15
16
# File 'lib/ruby_home/factories/accessory_factory.rb', line 12

def initialize(service_name, accessory_options, characteristic_options)
  @service_name = service_name
  @accessory_options = accessory_options
  @characteristic_options = characteristic_options
end

Class Method Details

.create(service_name, characteristics: {}, **options) ⇒ Object



8
9
10
# File 'lib/ruby_home/factories/accessory_factory.rb', line 8

def self.create(service_name, characteristics: {}, **options)
  new(service_name, options, characteristics).create
end

Instance Method Details

#create {|service| ... } ⇒ Object

Yields:

  • (service)


18
19
20
21
22
23
24
25
26
27
# File 'lib/ruby_home/factories/accessory_factory.rb', line 18

def create
  yield service if block_given?

  create_accessory_information
  service.save
  create_required_characteristics
  create_optional_characteristics

  service
end