Class: TimexDatalinkClient::Protocol3::Time
- Inherits:
-
Object
- Object
- TimexDatalinkClient::Protocol3::Time
- Includes:
- Helpers::CharEncoders, Helpers::CrcPacketsWrapper
- Defined in:
- lib/timex_datalink_client/protocol_3/time.rb
Constant Summary collapse
- CPACKET_TIME =
[0x32]
- DATE_FORMAT_MAP =
{ "%_m-%d-%y" => 0, "%_d-%m-%y" => 1, "%y-%m-%d" => 2, "%_m.%d.%y" => 4, "%_d.%m.%y" => 5, "%y.%m.%d" => 6 }.freeze
Constants included from Helpers::CharEncoders
Helpers::CharEncoders::CHARS, Helpers::CharEncoders::EEPROM_CHARS, Helpers::CharEncoders::EEPROM_TERMINATOR, Helpers::CharEncoders::INVALID_CHAR, Helpers::CharEncoders::PHONE_CHARS
Instance Attribute Summary collapse
-
#date_format ⇒ Object
Returns the value of attribute date_format.
-
#is_24h ⇒ Object
Returns the value of attribute is_24h.
-
#time ⇒ Object
Returns the value of attribute time.
-
#zone ⇒ Object
Returns the value of attribute zone.
Instance Method Summary collapse
-
#initialize(zone:, is_24h:, date_format:, time:, name: nil) ⇒ Time
constructor
Create a Time instance.
-
#packets ⇒ Array<Array<Integer>>
Compile packets for a time.
Methods included from Helpers::CharEncoders
#chars_for, #eeprom_chars_for, #phone_chars_for
Constructor Details
#initialize(zone:, is_24h:, date_format:, time:, name: nil) ⇒ Time
Create a Time instance.
34 35 36 37 38 39 40 |
# File 'lib/timex_datalink_client/protocol_3/time.rb', line 34 def initialize(zone:, is_24h:, date_format:, time:, name: nil) @zone = zone @is_24h = is_24h @date_format = date_format @time = time @name = name end |
Instance Attribute Details
#date_format ⇒ Object
Returns the value of attribute date_format.
23 24 25 |
# File 'lib/timex_datalink_client/protocol_3/time.rb', line 23 def date_format @date_format end |
#is_24h ⇒ Object
Returns the value of attribute is_24h.
23 24 25 |
# File 'lib/timex_datalink_client/protocol_3/time.rb', line 23 def is_24h @is_24h end |
#time ⇒ Object
Returns the value of attribute time.
23 24 25 |
# File 'lib/timex_datalink_client/protocol_3/time.rb', line 23 def time @time end |
#zone ⇒ Object
Returns the value of attribute zone.
23 24 25 |
# File 'lib/timex_datalink_client/protocol_3/time.rb', line 23 def zone @zone end |
Instance Method Details
#packets ⇒ Array<Array<Integer>>
Compile packets for a time.
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/timex_datalink_client/protocol_3/time.rb', line 45 def packets [ [ CPACKET_TIME, zone, time.sec, time.hour, time.min, time.month, time.day, year_mod_1900, name_characters, wday_from_monday, is_24h_value, date_format_value ].flatten ] end |