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.



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

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



3
4
5
# File 'lib/ruby_home/factories/accessory_factory.rb', line 3

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

Instance Method Details

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

Yields:

  • (service)


13
14
15
16
17
18
19
20
21
22
# File 'lib/ruby_home/factories/accessory_factory.rb', line 13

def create
  yield service if block_given?

  create_accessory_information
  service.save
  create_required_characteristics
  create_optional_characteristics

  service
end