Class: TimexDatalinkClient::Protocol9::Eeprom::PhoneNumber

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

Constant Summary collapse

NAME_CHARS =
15
PHONE_DIGITS =
12
TYPE_DIGITS =
2

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.



25
26
27
28
29
# File 'lib/timex_datalink_client/protocol_9/eeprom/phone_number.rb', line 25

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

Instance Attribute Details

#nameObject

Returns the value of attribute name.



17
18
19
# File 'lib/timex_datalink_client/protocol_9/eeprom/phone_number.rb', line 17

def name
  @name
end

#numberObject

Returns the value of attribute number.



17
18
19
# File 'lib/timex_datalink_client/protocol_9/eeprom/phone_number.rb', line 17

def number
  @number
end

#typeObject

Returns the value of attribute type.



17
18
19
# File 'lib/timex_datalink_client/protocol_9/eeprom/phone_number.rb', line 17

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.



34
35
36
37
38
39
# File 'lib/timex_datalink_client/protocol_9/eeprom/phone_number.rb', line 34

def packet
  [
    number_with_type_characters,
    name_characters
  ].flatten
end