Class: Flic::Protocol::Primitives::Uuid

Inherits:
BinData::Primitive
  • Object
show all
Defined in:
lib/flic/protocol/primitives/uuid.rb

Overview

The uuid of a button (nil is represented as all zeros)

Constant Summary collapse

NULL_UUID_OCTETS =
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0].freeze
PRINTF_FORMAT_STRING =
'%.2X%.2X%.2X%.2X-%.2X%.2X-%.2X%.2X-%.2X%.2X-%.2X%.2X%.2X%.2X%.2X%.2X'.freeze
SCANF_FORMAT_STRING =
'%X%X%X%X-%X%X-%X%X-%X%X-%X%X%X%X%X%X'.freeze

Instance Method Summary collapse

Instance Method Details

#getObject



17
18
19
20
21
22
23
# File 'lib/flic/protocol/primitives/uuid.rb', line 17

def get
  if NULL_UUID_OCTETS == octets
    nil
  else
    sprintf(PRINTF_FORMAT_STRING, *octets)
  end
end

#set(value) ⇒ Object



25
26
27
28
29
30
31
# File 'lib/flic/protocol/primitives/uuid.rb', line 25

def set(value)
  if value
    self.octets = value.scanf(SCANF_FORMAT_STRING)
  else
    self.octets = NULL_UUID_OCTETS
  end
end