Class: TimexDatalinkClient::Protocol4::Eeprom::Anniversary

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

Constant Summary

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(time:, anniversary:) ⇒ Anniversary

Create an Anniversary instance.

Parameters:

  • time (::Time)

    Time of anniversary.

  • anniversary (String)

    Anniversary text.



20
21
22
23
# File 'lib/timex_datalink_client/protocol_4/eeprom/anniversary.rb', line 20

def initialize(time:, anniversary:)
  @time = time
  @anniversary = anniversary
end

Instance Attribute Details

#anniversaryObject

Returns the value of attribute anniversary.



13
14
15
# File 'lib/timex_datalink_client/protocol_4/eeprom/anniversary.rb', line 13

def anniversary
  @anniversary
end

#timeObject

Returns the value of attribute time.



13
14
15
# File 'lib/timex_datalink_client/protocol_4/eeprom/anniversary.rb', line 13

def time
  @time
end

Instance Method Details

#packetArray<Integer>

Compile a packet for an anniversary.

Returns:

  • (Array<Integer>)

    Array of integers that represent bytes.



28
29
30
31
32
33
34
# File 'lib/timex_datalink_client/protocol_4/eeprom/anniversary.rb', line 28

def packet
  [
    time.month,
    time.day,
    anniversary_characters
  ].flatten
end