string_dot_gradient 0.1.7 → 0.1.8
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
- data/lib/string_dot_gradient/gradient.rb +22 -28
- data/lib/string_dot_gradient/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7f734ad48d80c57969e3fb4598f5a89fafdb35b30c2b5dddbc1bbbf1a835a829
|
4
|
+
data.tar.gz: 80c268d0c7754047bf1040d1ade34a3e9652180441ca3cbf23a0d67f8873d531
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0102ffe6acc5355cc7d29dea013439eb245fc5ec11415eea6cc91f1025a6128f639120b74d29d0dec44ebf085f73d41411d6027480b4270dc832d17e5e353cf7
|
7
|
+
data.tar.gz: d0d2c157c03af2a8688fcba1ade8d5177e0d8656512b9293a26672faf9dddb492a530e409df9e6ffa5f32f75f05d0c6c041ac13f4cc0a75c4067b4fc59bf9144
|
@@ -50,8 +50,10 @@ class String
|
|
50
50
|
all_rgbs = flatten_colours.map!(&method(:hex_to_rgb))
|
51
51
|
block_given = block_given?
|
52
52
|
|
53
|
-
r, g, b
|
54
|
-
r2, g2, b2
|
53
|
+
# r, g, b => starting r, g, b
|
54
|
+
# r2, g2, b2 => stopping r, g, b
|
55
|
+
r, g, b = *all_rgbs[0]
|
56
|
+
r2, g2, b2 = *all_rgbs[1]
|
55
57
|
rotate = all_rgbs.length > 2
|
56
58
|
|
57
59
|
init = bg ? 48 : 38
|
@@ -62,53 +64,45 @@ class String
|
|
62
64
|
|
63
65
|
len = c.length
|
64
66
|
n_variable = exclude_spaces ? c.delete("\t\s".freeze).length : len
|
65
|
-
n_variable
|
67
|
+
n_variable -= 1
|
68
|
+
n_variable = 1 if n_variable < 1
|
66
69
|
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
r_comp_op = r_comp_val = nil
|
72
|
-
g_comp_op = g_comp_val = nil
|
73
|
-
b_comp_op = b_comp_val = nil
|
70
|
+
# colour operator, colour value
|
71
|
+
r_op = r_val = nil
|
72
|
+
g_op = g_val = nil
|
73
|
+
b_op = b_val = nil
|
74
74
|
|
75
75
|
if r2 > r
|
76
|
-
r_op, r_val
|
77
|
-
r_comp_op, r_comp_val = :<=, r_max
|
76
|
+
r_op, r_val = :+, r2.-(r).fdiv(n_variable)
|
78
77
|
elsif r2 < r
|
79
|
-
r_op, r_val
|
80
|
-
r_comp_op, r_comp_val = :>=, r_min
|
78
|
+
r_op, r_val = :-, r.-(r2).fdiv(n_variable)
|
81
79
|
end
|
82
80
|
|
83
81
|
if g2 > g
|
84
|
-
g_op, g_val
|
85
|
-
g_comp_op, g_comp_val = :<=, g_max
|
82
|
+
g_op, g_val = :+, g2.-(g).fdiv(n_variable)
|
86
83
|
elsif g2 < g
|
87
|
-
g_op, g_val
|
88
|
-
g_comp_op, g_comp_val = :>=, g_min
|
84
|
+
g_op, g_val = :-, g.-(g2).fdiv(n_variable)
|
89
85
|
end
|
90
86
|
|
91
87
|
if b2 > b
|
92
|
-
b_op, b_val
|
93
|
-
b_comp_op, b_comp_val = :<=, b_max
|
88
|
+
b_op, b_val = :+, b2.-(b).fdiv(n_variable)
|
94
89
|
elsif b2 < b
|
95
|
-
b_op, b_val
|
96
|
-
b_comp_op, b_comp_val = :>=, b_min
|
90
|
+
b_op, b_val = :-, b.-(b2).fdiv(n_variable)
|
97
91
|
end
|
98
92
|
|
99
93
|
# To avoid the value getting adding | subtracted from the initial character
|
100
|
-
_r = _r.send(r_op, r_val * -1) if
|
101
|
-
_g = _g.send(g_op, g_val * -1) if
|
102
|
-
_b = _b.send(b_op, b_val * -1) if
|
94
|
+
_r = _r.send(r_op, r_val * -1) if r_op
|
95
|
+
_g = _g.send(g_op, g_val * -1) if g_op
|
96
|
+
_b = _b.send(b_op, b_val * -1) if b_op
|
103
97
|
|
104
98
|
i = -1
|
105
99
|
while (i += 1) < len
|
106
100
|
_c = c[i]
|
107
101
|
|
108
102
|
if !exclude_spaces || (exclude_spaces && !(_c == ?\s.freeze || _c == ?\t.freeze))
|
109
|
-
_r = _r.send(r_op, r_val) if
|
110
|
-
_g = _g.send(g_op, g_val) if
|
111
|
-
_b = _b.send(b_op, b_val) if
|
103
|
+
_r = _r.send(r_op, r_val) if r_op
|
104
|
+
_g = _g.send(g_op, g_val) if g_op
|
105
|
+
_b = _b.send(b_op, b_val) if b_op
|
112
106
|
end
|
113
107
|
|
114
108
|
r_to_i = _r.to_i
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: string_dot_gradient
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sourav Goswami
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-01-
|
11
|
+
date: 2021-01-12 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: An itty-bitty extension that adds gradient method to String class that
|
14
14
|
supports any hex colour, for Linux | Unix terminals only
|