Class: RubyHome::HTTP::CharacteristicSerializer

Inherits:
Object
  • Object
show all
Includes:
ObjectSerializer
Defined in:
lib/ruby_home/http/serializers/characteristic_serializer.rb

Instance Method Summary collapse

Methods included from ObjectSerializer

#initialize, #root, #serializable_hash, #serialized_json

Instance Method Details

#record_hash(characteristic) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/ruby_home/http/serializers/characteristic_serializer.rb', line 8

def record_hash(characteristic)
  record_hash = {}

  record_hash['iid'] = characteristic.instance_id
  record_hash['type'] = characteristic.uuid
  record_hash['perms'] = characteristic.properties.map do |property|
    RubyHome::Characteristic::PROPERTIES[property]
  end.compact
  record_hash['format'] = characteristic.format
  if characteristic.value != nil
    record_hash['value'] = characteristic.value
  end
  record_hash['description'] = characteristic.description

  record_hash
end