Class: Flic::Protocol::Primitives::DeviceName
- Inherits:
-
BinData::Primitive
- Object
- BinData::Primitive
- Flic::Protocol::Primitives::DeviceName
- Defined in:
- lib/flic/protocol/primitives/device_name.rb
Overview
The name of a device (up to 16 character string)
Constant Summary collapse
- BYTE_LENGTH =
16
Instance Method Summary collapse
Instance Method Details
#get ⇒ Object
15 16 17 18 19 20 21 22 |
# 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) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# 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 |