Class: TimexDatalinkClient::Protocol9::TimeName

Inherits:
Object
  • Object
show all
Includes:
ActiveModel::Validations, Helpers::CharEncoders, Helpers::CrcPacketsWrapper
Defined in:
lib/timex_datalink_client/protocol_9/time_name.rb

Constant Summary collapse

CPACKET_NAME =
[0x31]

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(zone:, name:) ⇒ TimeName

Create a TimeName instance.

Parameters:

  • zone (Integer)

    Time zone number (1 or 2).

  • name (String)

    Name of time zone (3 chars max).



29
30
31
32
# File 'lib/timex_datalink_client/protocol_9/time_name.rb', line 29

def initialize(zone:, name:)
  @zone = zone
  @name = name
end

Instance Attribute Details

#nameObject

Returns the value of attribute name.



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

def name
  @name
end

#zoneObject

Returns the value of attribute zone.



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

def zone
  @zone
end

Instance Method Details

#packetsArray<Array<Integer>>

Compile packets for a time name.

Returns:

  • (Array<Array<Integer>>)

    Two-dimensional array of integers that represent bytes.

Raises:

  • (ActiveModel::ValidationError)

    One or more model values are invalid.



38
39
40
41
42
43
44
45
46
47
48
# File 'lib/timex_datalink_client/protocol_9/time_name.rb', line 38

def packets
  validate!

  [
    [
      CPACKET_NAME,
      zone,
      name_characters
    ].flatten
  ]
end