Class: TimexDatalinkClient::Protocol3::Time
- Inherits:
-
Object
- Object
- TimexDatalinkClient::Protocol3::Time
- Includes:
- ActiveModel::Validations, 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::CHARS_PROTOCOL_6, 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.
-
#name ⇒ Object
Returns the value of attribute name.
-
#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, #protocol_6_chars_for
Constructor Details
#initialize(zone:, is_24h:, date_format:, time:, name: nil) ⇒ Time
Create a Time instance.
47 48 49 50 51 52 53 |
# File 'lib/timex_datalink_client/protocol_3/time.rb', line 47 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.
36 37 38 |
# File 'lib/timex_datalink_client/protocol_3/time.rb', line 36 def date_format @date_format end |
#is_24h ⇒ Object
Returns the value of attribute is_24h.
36 37 38 |
# File 'lib/timex_datalink_client/protocol_3/time.rb', line 36 def is_24h @is_24h end |
#name ⇒ Object
Returns the value of attribute name.
36 37 38 |
# File 'lib/timex_datalink_client/protocol_3/time.rb', line 36 def name @name end |
#time ⇒ Object
Returns the value of attribute time.
36 37 38 |
# File 'lib/timex_datalink_client/protocol_3/time.rb', line 36 def time @time end |
#zone ⇒ Object
Returns the value of attribute zone.
36 37 38 |
# File 'lib/timex_datalink_client/protocol_3/time.rb', line 36 def zone @zone end |
Instance Method Details
#packets ⇒ Array<Array<Integer>>
Compile packets for a time.
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/timex_datalink_client/protocol_3/time.rb', line 59 def packets validate! [ [ 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 |