Class: RubyHome::Characteristic

Inherits:
Object
  • Object
show all
Includes:
Wisper::Publisher
Defined in:
lib/ruby_home/hap/characteristic.rb

Constant Summary collapse

PROPERTIES =
{
  'cnotify' => 'ev',
  'read' => 'pr',
  'uncnotify' => nil,
  'write' => 'pw',
}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(uuid:, name:, description:, format:, unit:, properties:, service:, value: nil) ⇒ Characteristic

Returns a new instance of Characteristic.



26
27
28
29
30
31
32
33
34
35
# File 'lib/ruby_home/hap/characteristic.rb', line 26

def initialize(uuid:, name:, description:, format:, unit:, properties:, service: , value: nil)
  @uuid = uuid
  @name = name
  @description = description
  @format = format
  @unit = unit
  @properties = properties
  @service = service
  @value = value
end

Instance Attribute Details

#descriptionObject (readonly)

Returns the value of attribute description.



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

def description
  @description
end

#formatObject (readonly)

Returns the value of attribute format.



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

def format
  @format
end

#instance_idObject

Returns the value of attribute instance_id.



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

def instance_id
  @instance_id
end

#nameObject (readonly)

Returns the value of attribute name.



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

def name
  @name
end

#propertiesObject (readonly)

Returns the value of attribute properties.



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

def properties
  @properties
end

#serviceObject (readonly)

Returns the value of attribute service.



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

def service
  @service
end

#unitObject (readonly)

Returns the value of attribute unit.



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

def unit
  @unit
end

#uuidObject (readonly)

Returns the value of attribute uuid.



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

def uuid
  @uuid
end

Instance Method Details

#after_update(&block) ⇒ Object



15
16
17
# File 'lib/ruby_home/hap/characteristic.rb', line 15

def after_update(&block)
  on(:after_update, &block)
end

#service_iidObject



57
58
59
# File 'lib/ruby_home/hap/characteristic.rb', line 57

def service_iid
  service.instance_id
end

#unsubscribe(*listeners) ⇒ Object



9
10
11
12
13
# File 'lib/ruby_home/hap/characteristic.rb', line 9

def unsubscribe(*listeners)
  local_registrations.delete_if do |registration|
    listeners.include?(registration.listener)
  end
end

#valueObject



61
62
63
# File 'lib/ruby_home/hap/characteristic.rb', line 61

def value
  @value.value
end

#value=(new_value) ⇒ Object



65
66
67
68
# File 'lib/ruby_home/hap/characteristic.rb', line 65

def value=(new_value)
  @value.value = new_value
  broadcast(:after_update, self)
end