Class: RubyHome::HTTP::CharacteristicSerializer
- Inherits:
-
Object
- Object
- RubyHome::HTTP::CharacteristicSerializer
show all
- Includes:
- ObjectSerializer, UUIDHelper
- Defined in:
- lib/ruby_home/http/serializers/characteristic_serializer.rb
Constant Summary
Constants included
from UUIDHelper
UUIDHelper::APPLE_BASE_UUID
Instance Method Summary
collapse
Methods included from UUIDHelper
#apple_defined_uuid?, #trim_leading_zeros, #uuid_short_form
#initialize, #root, #serializable_hash, #serialized_json
Instance Method Details
#optional_hash(characteristic) ⇒ Object
26
27
28
29
30
31
32
|
# File 'lib/ruby_home/http/serializers/characteristic_serializer.rb', line 26
def optional_hash(characteristic)
Hash.new.tap do |optional_hash|
if characteristic.value != nil
optional_hash['value'] = characteristic.value
end
end
end
|
#perms(characteristic) ⇒ Object
20
21
22
23
24
|
# File 'lib/ruby_home/http/serializers/characteristic_serializer.rb', line 20
def perms(characteristic)
characteristic.properties.map do |property|
RubyHome::Characteristic::PROPERTIES[property]
end.compact
end
|
#record_hash(characteristic) ⇒ Object
10
11
12
13
14
15
16
17
18
|
# File 'lib/ruby_home/http/serializers/characteristic_serializer.rb', line 10
def record_hash(characteristic)
{
'iid' => characteristic.instance_id,
'type' => uuid_short_form(characteristic.uuid),
'perms' => perms(characteristic),
'format' => characteristic.format,
'description' => characteristic.description,
}.merge(optional_hash(characteristic))
end
|