class Flic::Protocol::Primitives::DeviceName

The name of a device (up to 16 character string)

Constants

BYTE_LENGTH

Public Instance Methods

get() click to toggle source
# File lib/flic/protocol/primitives/device_name.rb, line 15
def get
  ''.tap do |string|
    byte_length.times do |index|
      break unless index < BYTE_LENGTH
      string << bytes[index].to_i
    end
  end
end
set(value) click to toggle source
# File lib/flic/protocol/primitives/device_name.rb, line 24
def set(value)
  byte_length = 0
  bytes = []

  BYTE_LENGTH.times do |index|
    char = value[index].to_s

    if char
      bytes << char.ord
      byte_length += 1
    else
      bytes << 0
    end
  end

  self.byte_length = byte_length
  self.bytes = bytes
end