Class: RubyHome::HTTP::CharacteristicSerializer
- Inherits:
-
Object
- Object
- RubyHome::HTTP::CharacteristicSerializer
show all
- Includes:
- ObjectSerializer
- Defined in:
- lib/ruby_home/http/serializers/characteristic_serializer.rb
Instance Method Summary
collapse
#initialize, #root, #serializable_hash, #serialized_json
Instance Method Details
#optional_hash(characteristic) ⇒ Object
24
25
26
27
28
29
30
|
# File 'lib/ruby_home/http/serializers/characteristic_serializer.rb', line 24
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
18
19
20
21
22
|
# File 'lib/ruby_home/http/serializers/characteristic_serializer.rb', line 18
def perms(characteristic)
characteristic.properties.map do |property|
RubyHome::Characteristic::PROPERTIES[property]
end.compact
end
|
#record_hash(characteristic) ⇒ Object
8
9
10
11
12
13
14
15
16
|
# File 'lib/ruby_home/http/serializers/characteristic_serializer.rb', line 8
def record_hash(characteristic)
{
'iid' => characteristic.instance_id,
'type' => characteristic.uuid,
'perms' => perms(characteristic),
'format' => characteristic.format,
'description' => characteristic.description,
}.merge(optional_hash(characteristic))
end
|