Class: TimexDatalinkClient::Protocol1::Alarm
- Inherits:
-
Object
- Object
- TimexDatalinkClient::Protocol1::Alarm
- Includes:
- ActiveModel::Validations, Helpers::CharEncoders, Helpers::CrcPacketsWrapper
- Defined in:
- lib/timex_datalink_client/protocol_1/alarm.rb
Constant Summary collapse
- CPACKET_ALARM =
[0x50]
- CPACKET_ALARM_SILENT =
[0x70, 0x00]
- ALARM_SILENT_START_INDEX =
0x61
- VALID_DAYS_IN_MONTH =
{ 1 => 1..31, 2 => 1..29, 3 => 1..31, 4 => 1..30, 5 => 1..31, 6 => 1..30, 7 => 1..31, 8 => 1..31, 9 => 1..30, 10 => 1..31, 11 => 1..30, 12 => 1..31 }.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
-
#audible ⇒ Object
Returns the value of attribute audible.
-
#day ⇒ Object
Returns the value of attribute day.
-
#message ⇒ Object
Returns the value of attribute message.
-
#month ⇒ Object
Returns the value of attribute month.
-
#number ⇒ Object
Returns the value of attribute number.
-
#time ⇒ Object
Returns the value of attribute time.
Instance Method Summary collapse
-
#initialize(number:, audible:, time:, message:, month: nil, day: nil) ⇒ Alarm
constructor
Create an Alarm instance.
-
#packets ⇒ Array<Array<Integer>>
Compile packets for an alarm.
Methods included from Helpers::CharEncoders
#chars_for, #eeprom_chars_for, #phone_chars_for, #protocol_6_chars_for
Constructor Details
#initialize(number:, audible:, time:, message:, month: nil, day: nil) ⇒ Alarm
Create an Alarm instance.
73 74 75 76 77 78 79 80 |
# File 'lib/timex_datalink_client/protocol_1/alarm.rb', line 73 def initialize(number:, audible:, time:, message:, month: nil, day: nil) @number = number @audible = audible @time = time @message = @month = month @day = day end |
Instance Attribute Details
#audible ⇒ Object
Returns the value of attribute audible.
35 36 37 |
# File 'lib/timex_datalink_client/protocol_1/alarm.rb', line 35 def audible @audible end |
#day ⇒ Object
Returns the value of attribute day.
35 36 37 |
# File 'lib/timex_datalink_client/protocol_1/alarm.rb', line 35 def day @day end |
#message ⇒ Object
Returns the value of attribute message.
35 36 37 |
# File 'lib/timex_datalink_client/protocol_1/alarm.rb', line 35 def @message end |
#month ⇒ Object
Returns the value of attribute month.
35 36 37 |
# File 'lib/timex_datalink_client/protocol_1/alarm.rb', line 35 def month @month end |
#number ⇒ Object
Returns the value of attribute number.
35 36 37 |
# File 'lib/timex_datalink_client/protocol_1/alarm.rb', line 35 def number @number end |
#time ⇒ Object
Returns the value of attribute time.
35 36 37 |
# File 'lib/timex_datalink_client/protocol_1/alarm.rb', line 35 def time @time end |
Instance Method Details
#packets ⇒ Array<Array<Integer>>
Compile packets for an alarm.
86 87 88 89 90 91 92 |
# File 'lib/timex_datalink_client/protocol_1/alarm.rb', line 86 def packets validate! [alarm_data_packet].tap do |packets| packets << alarm_silent_packet unless audible end end |