more_math 1.2.0 → 1.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGES.md +6 -0
- data/lib/more_math/histogram.rb +14 -2
- data/lib/more_math/version.rb +1 -1
- data/more_math.gemspec +2 -2
- data/tests/histogram_test.rb +2 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c2945331f84849efc01cafcdd9dec0e1402a6296c979d6b6d5ecb41ff49427a2
|
4
|
+
data.tar.gz: 2e25d9b28a5c326eb50d7ca12ef66d0562f8e5839a8f9c37a9db504fc13c286c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 11a42069a9e921c857849cceb0f912a3989a4bf046645be765c8acb54f9bea299ced8790be585fd04367531e6484847866cde89486c7aa6943fb396d80bfcf31
|
7
|
+
data.tar.gz: ee3e2b0ba782557eb94770833b0e98494254ce1a138caf493e72d208b54f56bb62645bd0779e71c84b32b949df2b8de3f4424c2c107b3c609a7bd5901a2cd471
|
data/CHANGES.md
CHANGED
@@ -1,5 +1,11 @@
|
|
1
1
|
# Changes
|
2
2
|
|
3
|
+
## 2024-09-30 v1.2.1
|
4
|
+
|
5
|
+
* Refactor histogram display logic for utf8 and ascii bars
|
6
|
+
+ *Improved `utf8_bar` method to handle fractional bar widths.*
|
7
|
+
+ *Updated test case in `histogram_test.rb` to reflect changes.*
|
8
|
+
|
3
9
|
## 2024-09-30 v1.2.0
|
4
10
|
|
5
11
|
#### Significant Changes
|
data/lib/more_math/histogram.rb
CHANGED
@@ -53,7 +53,11 @@ module MoreMath
|
|
53
53
|
def utf8_bar(bar_width)
|
54
54
|
fract = bar_width - bar_width.floor
|
55
55
|
bar = ?⣿ * bar_width.floor
|
56
|
-
fract > 0.5
|
56
|
+
if fract > 0.5
|
57
|
+
bar << ?⡇
|
58
|
+
else
|
59
|
+
bar << ' '
|
60
|
+
end
|
57
61
|
bar
|
58
62
|
end
|
59
63
|
|
@@ -80,7 +84,15 @@ module MoreMath
|
|
80
84
|
bar_width = (count * factor)
|
81
85
|
bar = utf8? ? utf8_bar(bar_width) : ascii_bar(bar_width)
|
82
86
|
if @with_counts
|
83
|
-
|
87
|
+
if utf8?
|
88
|
+
if bar[-1] == ' '
|
89
|
+
bar += count.to_s.rjust(width - bar_width - 1)
|
90
|
+
else
|
91
|
+
bar += count.to_s.rjust(width - bar_width)
|
92
|
+
end
|
93
|
+
else
|
94
|
+
bar += count.to_s.rjust(width - bar_width)
|
95
|
+
end
|
84
96
|
end
|
85
97
|
"%11.5f -|%s\n" % [ (left + right) / 2.0, bar ]
|
86
98
|
end
|
data/lib/more_math/version.rb
CHANGED
data/more_math.gemspec
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
|
-
# stub: more_math 1.2.
|
2
|
+
# stub: more_math 1.2.1 ruby lib
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
5
5
|
s.name = "more_math".freeze
|
6
|
-
s.version = "1.2.
|
6
|
+
s.version = "1.2.1".freeze
|
7
7
|
|
8
8
|
s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
|
9
9
|
s.require_paths = ["lib".freeze]
|
data/tests/histogram_test.rb
CHANGED
@@ -60,9 +60,9 @@ class HistogramTest < Test::Unit::TestCase
|
|
60
60
|
output = StringIO.new
|
61
61
|
histogram.display output
|
62
62
|
assert_equal <<~end, output.string
|
63
|
-
7.50000 -|⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿
|
63
|
+
7.50000 -|⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿
|
64
64
|
4.50000 -|⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡇
|
65
|
-
1.50000 -|⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿
|
65
|
+
1.50000 -|⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿
|
66
66
|
max_count=420
|
67
67
|
end
|
68
68
|
end
|