timex_datalink_client 0.3.1 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 499c12fec3a8fae40770efc4173421e0a996b999a98a19a7e9ec64295628d757
|
4
|
+
data.tar.gz: 29b1bec826b2d5a2c25f7d7c9e47405760a2c08526e04f7f84084587dfec44c5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1278164bd72754ee49ad9d26b7cf3a953de3f164e6bb19a42a30a34528ed012b6d967f605aeb244b6554ca29541312edec4b4d2730c1fadfa38b9946d862e76e
|
7
|
+
data.tar.gz: ad536dfbf0e894b5474be3fc36c4c8b0387cdc47e7134c58c98e7c6978ac004a78b20c4f54059e63d8cc3accda0e7b2f60199920be8bdbe128d98afa62798727
|
@@ -3,19 +3,23 @@
|
|
3
3
|
class TimexDatalinkClient
|
4
4
|
class Helpers
|
5
5
|
module CharEncoders
|
6
|
-
CHARS = "0123456789abcdefghijklmnopqrstuvwxyz !\"#$%&'()*+,-./:\\;=@?
|
6
|
+
CHARS = "0123456789abcdefghijklmnopqrstuvwxyz !\"#$%&'()*+,-./:\\;=@?_|<>[]"
|
7
|
+
|
7
8
|
EEPROM_TERMINATOR = 0x3f
|
8
9
|
|
9
10
|
PHONE_CHARS = "0123456789cfhpw "
|
10
11
|
|
11
|
-
def chars_for(string_chars, char_map: CHARS)
|
12
|
-
string_chars.
|
13
|
-
|
12
|
+
def chars_for(string_chars, char_map: CHARS, length: nil, pad: false)
|
13
|
+
formatted_chars = string_chars.downcase[0..length.to_i - 1]
|
14
|
+
formatted_chars = formatted_chars.ljust(length) if pad
|
15
|
+
|
16
|
+
formatted_chars.each_char.map do |char|
|
17
|
+
char_map.index(char)
|
14
18
|
end
|
15
19
|
end
|
16
20
|
|
17
21
|
def eeprom_chars_for(string_chars)
|
18
|
-
chars = chars_for(string_chars).append(EEPROM_TERMINATOR)
|
22
|
+
chars = chars_for(string_chars, length: 31).append(EEPROM_TERMINATOR)
|
19
23
|
|
20
24
|
packed_int = chars.each_with_index.sum do |char, index|
|
21
25
|
char << (6 * index)
|
@@ -25,7 +29,7 @@ class TimexDatalinkClient
|
|
25
29
|
end
|
26
30
|
|
27
31
|
def phone_chars_for(string_chars)
|
28
|
-
chars = chars_for(string_chars, char_map: PHONE_CHARS)
|
32
|
+
chars = chars_for(string_chars, char_map: PHONE_CHARS, length: 12)
|
29
33
|
|
30
34
|
packed_int = chars.each_with_index.sum do |char, index|
|
31
35
|
char << (4 * index)
|
@@ -18,12 +18,14 @@ class TimexDatalinkClient
|
|
18
18
|
# @param is_24h [Boolean] Toggle 24 hour time.
|
19
19
|
# @param date_format [Integer] Date format.
|
20
20
|
# @param time [::Time] Time to set (including time zone).
|
21
|
+
# @param name [String, nil] Name of time zone (defaults to zone from time; 3 chars max)
|
21
22
|
# @return [Time] Time instance.
|
22
|
-
def initialize(zone:, is_24h:, date_format:, time:)
|
23
|
+
def initialize(zone:, is_24h:, date_format:, time:, name: nil)
|
23
24
|
@zone = zone
|
24
25
|
@is_24h = is_24h
|
25
26
|
@date_format = date_format
|
26
27
|
@time = time
|
28
|
+
@name = name
|
27
29
|
end
|
28
30
|
|
29
31
|
# Compile packets for a time.
|
@@ -40,7 +42,7 @@ class TimexDatalinkClient
|
|
40
42
|
time.month,
|
41
43
|
time.day,
|
42
44
|
year_mod_1900,
|
43
|
-
|
45
|
+
name_characters,
|
44
46
|
wday_from_monday,
|
45
47
|
is_24h_value,
|
46
48
|
date_format
|
@@ -50,8 +52,12 @@ class TimexDatalinkClient
|
|
50
52
|
|
51
53
|
private
|
52
54
|
|
53
|
-
def
|
54
|
-
|
55
|
+
def name
|
56
|
+
@name || time.zone.downcase
|
57
|
+
end
|
58
|
+
|
59
|
+
def name_characters
|
60
|
+
chars_for(name, length: 3, pad: true)
|
55
61
|
end
|
56
62
|
|
57
63
|
def year_mod_1900
|
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.
|
4
|
+
version: 0.4.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-09-
|
11
|
+
date: 2022-09-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: crc
|