string-format 0.1.0 → 0.2.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 +4 -4
- checksums.yaml.gz.sig +0 -0
- data/lib/string/format/statistics.rb +9 -2
- data/lib/string/format/version.rb +1 -1
- data/readme.md +6 -0
- data/releases.md +6 -0
- data.tar.gz.sig +0 -0
- metadata +1 -1
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1dc27ae95d3d0efc9e330b3844d2e8a98ded08cc775309a99c23fe753eaeb9fa
|
4
|
+
data.tar.gz: bd2d9a31bab50d1379d5d6f93bb08d4e44802502b90ae898c0f8c57df09d963a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 56482395708aeff848836d5f07b3779aba7745333457ed0e40c39a1e94f14a6b8d2920d830ffd87141b2d99dc04572da07b9ee2b8a541b38837b34777a7ecd3b
|
7
|
+
data.tar.gz: 88ff4bebc80516c10afdc92ba5fbfdf519d969bf49fdd8eaf9d467bcb2c6ed1574fe2d08d2426a48a669597aec0f4ac5eb3ec637bbe581161710271da5a3f89c
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
@@ -6,8 +6,9 @@
|
|
6
6
|
module String::Format
|
7
7
|
# Format multiple statistics into a compact string.
|
8
8
|
# @parameter pairs [Hash] Hash of statistic names to values or [current, total] arrays.
|
9
|
+
# @parameter short [Boolean] Whether to use short keys (first letter only).
|
9
10
|
# @returns [String] A formatted statistics string.
|
10
|
-
def statistics(
|
11
|
+
def statistics(pairs, short: true)
|
11
12
|
pairs.map do |key, value|
|
12
13
|
case value
|
13
14
|
when Array
|
@@ -16,7 +17,13 @@ module String::Format
|
|
16
17
|
value = count(value)
|
17
18
|
end
|
18
19
|
|
19
|
-
|
20
|
+
if short
|
21
|
+
key = key.to_s[0].upcase
|
22
|
+
else
|
23
|
+
key = key.to_s.upcase
|
24
|
+
end
|
25
|
+
|
26
|
+
"#{key}=#{value}"
|
20
27
|
end.join(" ")
|
21
28
|
end
|
22
29
|
|
data/readme.md
CHANGED
@@ -14,8 +14,14 @@ Please see the [project documentation](https://socketry.github.io/string-format/
|
|
14
14
|
|
15
15
|
Please see the [project releases](https://socketry.github.io/string-format/releases/index) for all releases.
|
16
16
|
|
17
|
+
### v0.2.0
|
18
|
+
|
19
|
+
- `String::Format.statistics` takes pairs argument instead of keyword argument.
|
20
|
+
|
17
21
|
### v0.1.0
|
18
22
|
|
23
|
+
- Initial release.
|
24
|
+
|
19
25
|
## Contributing
|
20
26
|
|
21
27
|
We welcome contributions to this project.
|
data/releases.md
CHANGED
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
metadata.gz.sig
CHANGED
Binary file
|