Class: TimexDatalinkClient::Protocol6::Time
- Inherits:
-
Object
- Object
- TimexDatalinkClient::Protocol6::Time
- Includes:
- ActiveModel::Validations, Helpers::CharEncoders, Helpers::CrcPacketsWrapper
- Defined in:
- lib/timex_datalink_client/protocol_6/time.rb
Constant Summary collapse
- CPACKET_TIME =
[0x32].freeze
- CPACKET_FLEX_TIME =
[0x33].freeze
- ZONE_OFFSET_MAP =
{ -39600 => 0x15, -36000 => 0x16, -32400 => 0x17, -28800 => 0x18, -25200 => 0x19, -21600 => 0x1a, -18000 => 0x1b, -14400 => 0x1c, -12600 => 0x14, -10800 => 0x1d, -7200 => 0x1e, -3600 => 0x1f, 0 => 0x00, 3600 => 0x01, 7200 => 0x02, 10800 => 0x03, 12600 => 0x0d, 14400 => 0x04, 16200 => 0x0e, 18000 => 0x05, 19800 => 0x0f, 20700 => 0x11, 21600 => 0x06, 23400 => 0x12, 25200 => 0x07, 28800 => 0x08, 32400 => 0x09, 34200 => 0x13, 36000 => 0x0a, 39600 => 0x0b, 43200 => 0x0c }.freeze
- FLEX_TIME_ZONE =
0x10
- FLEX_DST_VALUE =
0x08
- DATE_FORMAT_MAP =
{ "%_m-%d-%y" => 0x00, "%_d-%m-%y" => 0x01, "%y-%m-%d" => 0x02, "%_m.%d.%y" => 0x04, "%_d.%m.%y" => 0x05, "%y.%m.%d" => 0x06 }.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.
-
#flex_dst ⇒ Object
Returns the value of attribute flex_dst.
-
#flex_time ⇒ Object
Returns the value of attribute flex_time.
-
#flex_time_zone ⇒ Object
Returns the value of attribute flex_time_zone.
-
#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, flex_time: false, flex_time_zone: false, flex_dst: false) ⇒ 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, flex_time: false, flex_time_zone: false, flex_dst: false) ⇒ Time
Create a Time instance.
98 99 100 101 102 103 104 105 106 107 108 109 |
# File 'lib/timex_datalink_client/protocol_6/time.rb', line 98 def initialize( zone:, is_24h:, date_format:, time:, name: nil, flex_time: false, flex_time_zone: false, flex_dst: false ) @zone = zone @is_24h = is_24h @date_format = date_format @time = time @name = name @flex_time = flex_time @flex_time_zone = flex_time_zone @flex_dst = flex_dst end |
Instance Attribute Details
#date_format ⇒ Object
Returns the value of attribute date_format.
84 85 86 |
# File 'lib/timex_datalink_client/protocol_6/time.rb', line 84 def date_format @date_format end |
#flex_dst ⇒ Object
Returns the value of attribute flex_dst.
84 85 86 |
# File 'lib/timex_datalink_client/protocol_6/time.rb', line 84 def flex_dst @flex_dst end |
#flex_time ⇒ Object
Returns the value of attribute flex_time.
84 85 86 |
# File 'lib/timex_datalink_client/protocol_6/time.rb', line 84 def flex_time @flex_time end |
#flex_time_zone ⇒ Object
Returns the value of attribute flex_time_zone.
84 85 86 |
# File 'lib/timex_datalink_client/protocol_6/time.rb', line 84 def flex_time_zone @flex_time_zone end |
#is_24h ⇒ Object
Returns the value of attribute is_24h.
84 85 86 |
# File 'lib/timex_datalink_client/protocol_6/time.rb', line 84 def is_24h @is_24h end |
#name ⇒ Object
Returns the value of attribute name.
84 85 86 |
# File 'lib/timex_datalink_client/protocol_6/time.rb', line 84 def name @name end |
#time ⇒ Object
Returns the value of attribute time.
84 85 86 |
# File 'lib/timex_datalink_client/protocol_6/time.rb', line 84 def time @time end |
#zone ⇒ Object
Returns the value of attribute zone.
84 85 86 |
# File 'lib/timex_datalink_client/protocol_6/time.rb', line 84 def zone @zone end |
Instance Method Details
#packets ⇒ Array<Array<Integer>>
Compile packets for a time.
115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 |
# File 'lib/timex_datalink_client/protocol_6/time.rb', line 115 def packets validate! [ [ cpacket, zone, second, hour, minute, month, day, year_mod_1900, name_characters, wday_from_monday, formatted_time_zone, is_24h_value, date_format_value ].flatten ] end |