Class: TimexDatalinkClient::Protocol9::Time

Inherits:
Object
  • Object
show all
Includes:
Helpers::CrcPacketsWrapper
Defined in:
lib/timex_datalink_client/protocol_9/time.rb

Constant Summary collapse

CPACKET_TIME =
[0x30]

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(zone:, is_24h:, time:) ⇒ Time

Create a Time instance.



20
21
22
23
24
# File 'lib/timex_datalink_client/protocol_9/time.rb', line 20

def initialize(zone:, is_24h:, time:)
  @zone = zone
  @is_24h = is_24h
  @time = time
end

Instance Attribute Details

#is_24hObject

Returns the value of attribute is_24h.



12
13
14
# File 'lib/timex_datalink_client/protocol_9/time.rb', line 12

def is_24h
  @is_24h
end

#timeObject

Returns the value of attribute time.



12
13
14
# File 'lib/timex_datalink_client/protocol_9/time.rb', line 12

def time
  @time
end

#zoneObject

Returns the value of attribute zone.



12
13
14
# File 'lib/timex_datalink_client/protocol_9/time.rb', line 12

def zone
  @zone
end

Instance Method Details

#packetsArray<Array<Integer>>

Compile packets for a time.



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/timex_datalink_client/protocol_9/time.rb', line 29

def packets
  [
    [
      CPACKET_TIME,
      zone,
      time.hour,
      time.min,
      time.month,
      time.day,
      year_mod_1900,
      wday_from_monday,
      time.sec,
      is_24h_value
    ].flatten
  ]
end