Class: RubyHome::Service

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(accessory:, name:, description:, uuid:, primary: false, hidden: false) ⇒ Service

Returns a new instance of Service.



7
8
9
10
11
12
13
14
15
16
# File 'lib/ruby_home/service.rb', line 7

def initialize(accessory:, name:, description:, uuid:, primary: false, hidden: false)
  @accessory = accessory
  @primary = primary
  @hidden = hidden
  @name = name
  @description = description
  @uuid = uuid
  @characteristics = CharacteristicCollection.new
  @linked = []
end

Instance Attribute Details

#accessoryObject (readonly)

Returns the value of attribute accessory.



18
19
20
# File 'lib/ruby_home/service.rb', line 18

def accessory
  @accessory
end

#characteristicsObject (readonly)

Returns the value of attribute characteristics.



18
19
20
# File 'lib/ruby_home/service.rb', line 18

def characteristics
  @characteristics
end

#descriptionObject (readonly)

Returns the value of attribute description.



18
19
20
# File 'lib/ruby_home/service.rb', line 18

def description
  @description
end

#hiddenObject (readonly)

Returns the value of attribute hidden.



18
19
20
# File 'lib/ruby_home/service.rb', line 18

def hidden
  @hidden
end

#instance_idObject

Returns the value of attribute instance_id.



18
19
20
# File 'lib/ruby_home/service.rb', line 18

def instance_id
  @instance_id
end

#linkedObject

Returns the value of attribute linked.



29
30
31
# File 'lib/ruby_home/service.rb', line 29

def linked
  @linked
end

#nameObject (readonly)

Returns the value of attribute name.



18
19
20
# File 'lib/ruby_home/service.rb', line 18

def name
  @name
end

#primaryObject (readonly)

Returns the value of attribute primary.



18
19
20
# File 'lib/ruby_home/service.rb', line 18

def primary
  @primary
end

#uuidObject (readonly)

Returns the value of attribute uuid.



18
19
20
# File 'lib/ruby_home/service.rb', line 18

def uuid
  @uuid
end

Instance Method Details

#accessory_idObject



41
42
43
# File 'lib/ruby_home/service.rb', line 41

def accessory_id
  accessory.id
end

#characteristic(characteristic_name) ⇒ Object



45
46
47
48
49
# File 'lib/ruby_home/service.rb', line 45

def characteristic(characteristic_name)
  characteristics.find do |characteristic|
    characteristic.name == characteristic_name
  end
end

#contains_instance_id?(instance_id) ⇒ Boolean

Returns:

  • (Boolean)


37
38
39
# File 'lib/ruby_home/service.rb', line 37

def contains_instance_id?(instance_id)
  self.instance_id == instance_id || characteristics.contains_instance_id?(instance_id)
end