Class: TimexDatalinkClient::Protocol7::Eeprom::Calendar::Event
- Inherits:
-
Object
- Object
- TimexDatalinkClient::Protocol7::Eeprom::Calendar::Event
- Includes:
- ActiveModel::Validations, Helpers::LsbMsbFormatter
- Defined in:
- lib/timex_datalink_client/protocol_7/eeprom/calendar/event.rb
Constant Summary collapse
- FIVE_MINUTES_SECONDS =
300
Instance Attribute Summary collapse
-
#device_time ⇒ Object
Returns the value of attribute device_time.
-
#phrase ⇒ Object
Returns the value of attribute phrase.
-
#time ⇒ Object
Returns the value of attribute time.
Instance Method Summary collapse
-
#initialize(time:, phrase:) ⇒ Event
constructor
Create an Event instance.
- #time_formatted(device_time) ⇒ Object
Methods included from Helpers::LsbMsbFormatter
Constructor Details
#initialize(time:, phrase:) ⇒ Event
Create an Event instance.
30 31 32 33 |
# File 'lib/timex_datalink_client/protocol_7/eeprom/calendar/event.rb', line 30 def initialize(time:, phrase:) @time = time @phrase = phrase end |
Instance Attribute Details
#device_time ⇒ Object
Returns the value of attribute device_time.
22 23 24 |
# File 'lib/timex_datalink_client/protocol_7/eeprom/calendar/event.rb', line 22 def device_time @device_time end |
#phrase ⇒ Object
Returns the value of attribute phrase.
22 23 24 |
# File 'lib/timex_datalink_client/protocol_7/eeprom/calendar/event.rb', line 22 def phrase @phrase end |
#time ⇒ Object
Returns the value of attribute time.
22 23 24 |
# File 'lib/timex_datalink_client/protocol_7/eeprom/calendar/event.rb', line 22 def time @time end |
Instance Method Details
#time_formatted(device_time) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/timex_datalink_client/protocol_7/eeprom/calendar/event.rb', line 35 def time_formatted(device_time) @device_time = device_time validate! device_time_midnight = Time.new(device_time.year, device_time.month, device_time.day) seconds = (time - device_time_midnight).to_i five_minutes = seconds / FIVE_MINUTES_SECONDS lsb_msb_format_for(five_minutes) end |