timex_datalink_client 0.8.0 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 93fe636dc699046ea5c14683b355f8c65bb162fb18ee91b3ffe27f4a72633808
4
- data.tar.gz: d9476317e2cce78a77247c277e77208969f6e8fa13059a2e0f7452f502f9b112
3
+ metadata.gz: efa331ee9142b5392695a07a8f904f6c967584bb2b39abe1a5fd3577150f4eaf
4
+ data.tar.gz: ba994a959bb3156a218bfe1faef05c8a51223b911c6c926152d15182178ade1d
5
5
  SHA512:
6
- metadata.gz: 313b6bc8ea78a28ee55534ff28648a6544a8aa7dcf1abd731461fc7b9c21ba3711d441de603d7f538666541d5fce4ca0d6206449a2b8cee6cf5d56a263f8691a
7
- data.tar.gz: df31c376348f69fd05ba4c0de720e443074f68d63788601610021e0328598af3cfa8a3f85789336d20e80aac90be5ac32526bc6872d208afdd2c6965582f1617
6
+ metadata.gz: 69b09f2da57887e8ca4cc8c4f4186c21a9bb10b57d05e839d0122a0158ffde4fe7896268c74d525cdff2caf941dd1506b54d4db4ce4cd620d7bbbffb6d4cfa2a
7
+ data.tar.gz: 4cc7a686c22c7aa1b2a987286b2ecf023b3a36b423ba2d6a47665b743b8e989a3d29ab718466634893ac7d559f8b4e9e67d25d3797bdea8e8a1a399d67fa9f37
@@ -11,13 +11,23 @@ class TimexDatalinkClient
11
11
 
12
12
  CPACKET_TIME = [0x32]
13
13
 
14
+ DATE_FORMAT_MAP = {
15
+ "%_m-%d-%y" => 0,
16
+ "%_d-%m-%y" => 1,
17
+ "%y-%m-%d" => 2,
18
+ "%_m.%d.%y" => 4,
19
+ "%_d.%m.%y" => 5,
20
+ "%y.%m.%d" => 6
21
+ }.freeze
22
+
14
23
  attr_accessor :zone, :is_24h, :date_format, :time
15
24
 
16
25
  # Create a Time instance.
17
26
  #
18
27
  # @param zone [Integer] Time zone number (1 or 2).
19
28
  # @param is_24h [Boolean] Toggle 24 hour time.
20
- # @param date_format [Integer] Date format.
29
+ # @param date_format ["%_m-%d-%y", "%_d-%m-%y", "%y-%m-%d", "%_m.%d.%y", "%_d.%m.%y", "%y.%m.%d"] Date format
30
+ # (represented by Time#strftime format).
21
31
  # @param time [::Time] Time to set (including time zone).
22
32
  # @param name [String, nil] Name of time zone (defaults to zone from time; 3 chars max)
23
33
  # @return [Time] Time instance.
@@ -46,7 +56,7 @@ class TimexDatalinkClient
46
56
  name_characters,
47
57
  wday_from_monday,
48
58
  is_24h_value,
49
- date_format
59
+ date_format_value
50
60
  ].flatten
51
61
  ]
52
62
  end
@@ -72,6 +82,10 @@ class TimexDatalinkClient
72
82
  def is_24h_value
73
83
  is_24h ? 2 : 1
74
84
  end
85
+
86
+ def date_format_value
87
+ DATE_FORMAT_MAP.fetch(date_format)
88
+ end
75
89
  end
76
90
  end
77
91
  end
@@ -11,13 +11,23 @@ class TimexDatalinkClient
11
11
 
12
12
  CPACKET_TIME = [0x32]
13
13
 
14
+ DATE_FORMAT_MAP = {
15
+ "%_m-%d-%y" => 0,
16
+ "%_d-%m-%y" => 1,
17
+ "%y-%m-%d" => 2,
18
+ "%_m.%d.%y" => 4,
19
+ "%_d.%m.%y" => 5,
20
+ "%y.%m.%d" => 6
21
+ }.freeze
22
+
14
23
  attr_accessor :zone, :is_24h, :date_format, :time
15
24
 
16
25
  # Create a Time instance.
17
26
  #
18
27
  # @param zone [Integer] Time zone number (1 or 2).
19
28
  # @param is_24h [Boolean] Toggle 24 hour time.
20
- # @param date_format [Integer] Date format.
29
+ # @param date_format ["%_m-%d-%y", "%_d-%m-%y", "%y-%m-%d", "%_m.%d.%y", "%_d.%m.%y", "%y.%m.%d"] Date format
30
+ # (represented by Time#strftime format).
21
31
  # @param time [::Time] Time to set (including time zone).
22
32
  # @param name [String, nil] Name of time zone (defaults to zone from time; 3 chars max)
23
33
  # @return [Time] Time instance.
@@ -46,7 +56,7 @@ class TimexDatalinkClient
46
56
  name_characters,
47
57
  wday_from_monday,
48
58
  is_24h_value,
49
- date_format
59
+ date_format_value
50
60
  ].flatten
51
61
  ]
52
62
  end
@@ -72,6 +82,10 @@ class TimexDatalinkClient
72
82
  def is_24h_value
73
83
  is_24h ? 2 : 1
74
84
  end
85
+
86
+ def date_format_value
87
+ DATE_FORMAT_MAP.fetch(date_format)
88
+ end
75
89
  end
76
90
  end
77
91
  end
@@ -11,6 +11,12 @@ class TimexDatalinkClient
11
11
 
12
12
  CPACKET_TIMER = [0x43]
13
13
 
14
+ ACTION_AT_END_MAP = {
15
+ stop_timer: 0,
16
+ repeat_timer: 1,
17
+ start_chrono: 2
18
+ }.freeze
19
+
14
20
  attr_accessor :number, :label, :time, :action_at_end
15
21
 
16
22
  # Create a Timer instance.
@@ -18,7 +24,7 @@ class TimexDatalinkClient
18
24
  # @param number [Integer] Entry number for timer.
19
25
  # @param label [String] Label for timer.
20
26
  # @param time [Time] Time of timer.
21
- # @param action_at_end [Integer] Action at end of timer.
27
+ # @param action_at_end [:stop_timer, :repeat_timer, :start_chrono] Action at end of timer.
22
28
  # @return [Timer] Timer instance.
23
29
  def initialize(number:, label:, time:, action_at_end:)
24
30
  @number = number
@@ -38,7 +44,7 @@ class TimexDatalinkClient
38
44
  time.hour,
39
45
  time.min,
40
46
  time.sec,
41
- action_at_end,
47
+ action_at_end_value,
42
48
  label_characters
43
49
  ].flatten
44
50
  ]
@@ -46,6 +52,10 @@ class TimexDatalinkClient
46
52
 
47
53
  private
48
54
 
55
+ def action_at_end_value
56
+ ACTION_AT_END_MAP.fetch(action_at_end)
57
+ end
58
+
49
59
  def label_characters
50
60
  chars_for(label, length: 8, pad: true)
51
61
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class TimexDatalinkClient
4
- VERSION = "0.8.0"
4
+ VERSION = "0.9.0"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: timex_datalink_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.0
4
+ version: 0.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Maxwell Pray
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-12-13 00:00:00.000000000 Z
11
+ date: 2022-12-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: crc
@@ -167,7 +167,7 @@ files:
167
167
  - lib/timex_datalink_client/protocol_9/time_name.rb
168
168
  - lib/timex_datalink_client/protocol_9/timer.rb
169
169
  - lib/timex_datalink_client/version.rb
170
- homepage: https://github.com/synthead/timex_datalink_client/tree/v0.8.0
170
+ homepage: https://github.com/synthead/timex_datalink_client/tree/v0.9.0
171
171
  licenses:
172
172
  - MIT
173
173
  metadata: {}