Class: TimexDatalinkClient::Protocol6::Eeprom::PhoneNumber

Inherits:
Object
  • Object
show all
Includes:
Helpers::CharEncoders, Helpers::LengthPacketWrapper
Defined in:
lib/timex_datalink_client/protocol_6/eeprom/phone_number.rb

Constant Summary collapse

PHONE_DIGITS =
12
NAME_MAX_LENGTH =
31
NUMBER_NAME_DELIMITER =
"-"
NUMBER_NAME_MAX_NUMBER_LENGTH =
30
TERMINATOR =
0x5c

Constants included from Helpers::CharEncoders

Helpers::CharEncoders::CHARS, Helpers::CharEncoders::CHARS_PROTOCOL_6, Helpers::CharEncoders::EEPROM_CHARS, Helpers::CharEncoders::EEPROM_TERMINATOR, Helpers::CharEncoders::INVALID_CHAR, Helpers::CharEncoders::PHONE_CHARS

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Helpers::CharEncoders

#chars_for, #eeprom_chars_for, #phone_chars_for, #protocol_6_chars_for

Constructor Details

#initialize(name:, number:, type: " ") ⇒ PhoneNumber

Create a PhoneNumber instance.

Parameters:

  • name (String)

    Name associated to phone number.

  • number (String)

    Phone number text.

  • type (String) (defaults to: " ")

    Phone number type.



29
30
31
32
33
# File 'lib/timex_datalink_client/protocol_6/eeprom/phone_number.rb', line 29

def initialize(name:, number:, type: " ")
  @name = name
  @number = number
  @type = type
end

Instance Attribute Details

#nameObject

Returns the value of attribute name.



21
22
23
# File 'lib/timex_datalink_client/protocol_6/eeprom/phone_number.rb', line 21

def name
  @name
end

#numberObject

Returns the value of attribute number.



21
22
23
# File 'lib/timex_datalink_client/protocol_6/eeprom/phone_number.rb', line 21

def number
  @number
end

#typeObject

Returns the value of attribute type.



21
22
23
# File 'lib/timex_datalink_client/protocol_6/eeprom/phone_number.rb', line 21

def type
  @type
end

Instance Method Details

#packetArray<Integer>

Compile a packet for a phone number.

Returns:

  • (Array<Integer>)

    Array of integers that represent bytes.



38
39
40
41
42
43
44
# File 'lib/timex_datalink_client/protocol_6/eeprom/phone_number.rb', line 38

def packet
  [
    number_with_type_characters,
    name_characters,
    TERMINATOR
  ].flatten
end