Module: RubyHome::HTTP::UUIDHelper

Included in:
CharacteristicSerializer, ServiceSerializer
Defined in:
lib/ruby_home/http/serializers/uuid_helper.rb

Constant Summary collapse

APPLE_BASE_UUID =
-'0000-1000-8000-0026BB765291'

Instance Method Summary collapse

Instance Method Details

#apple_defined_uuid?(uuid) ⇒ Boolean

Returns:

  • (Boolean)


12
13
14
# File 'lib/ruby_home/http/serializers/uuid_helper.rb', line 12

def apple_defined_uuid?(uuid)
  uuid.end_with?(APPLE_BASE_UUID)
end

#trim_leading_zeros(input) ⇒ Object



16
17
18
# File 'lib/ruby_home/http/serializers/uuid_helper.rb', line 16

def trim_leading_zeros(input)
  input.gsub(/^0*/, '')
end

#uuid_short_form(uuid) ⇒ Object



6
7
8
9
10
# File 'lib/ruby_home/http/serializers/uuid_helper.rb', line 6

def uuid_short_form(uuid)
  return uuid unless apple_defined_uuid?(uuid)

  trim_leading_zeros(uuid[0...8])
end