string_dot_gradient 0.3.0 → 0.3.2
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 +25 -7
- data/lib/string_dot_gradient/version.rb +1 -1
- 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: dee7487ec82cd9435b163e3c3659c8147e2e8b6b7cd6b4220888d9ad213a6e5c
|
4
|
+
data.tar.gz: 9006ef1191185c26ebef6801c6c33cd3d5fd7ef1371c8924575e82b6055798e9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 89ad6e5d4244d86504367ebf61763feace21fd0fa93d381978ecf7ab865e334029a42535cff4b74213daccdb43b0e66c9cd8771f9bb0af4acbd045ae63bd5418
|
7
|
+
data.tar.gz: 84c5f8b2f25a85c2ed0aa94ee902284bafd51e321902ce094043f04e2a7dba64f3bd0eafa428d002ef9e626492d95fa29d79bc8718339e5698a2c553182e76e4
|
@@ -155,7 +155,11 @@ class String
|
|
155
155
|
ret = "\e[#{init};2;#{f_r};#{f_g};#{f_b}m#{_c}"
|
156
156
|
|
157
157
|
if block_given
|
158
|
-
|
158
|
+
if style && i == 0
|
159
|
+
yield style + ret
|
160
|
+
else
|
161
|
+
yield ret
|
162
|
+
end
|
159
163
|
else
|
160
164
|
temp << ret
|
161
165
|
end
|
@@ -168,7 +172,11 @@ class String
|
|
168
172
|
end
|
169
173
|
|
170
174
|
if block_given
|
171
|
-
|
175
|
+
if style
|
176
|
+
yield style + ret
|
177
|
+
else
|
178
|
+
yield ret
|
179
|
+
end
|
172
180
|
else
|
173
181
|
temp << ret
|
174
182
|
end
|
@@ -203,7 +211,8 @@ class String
|
|
203
211
|
blink: false,
|
204
212
|
strikethrough: false,
|
205
213
|
double_underline: false,
|
206
|
-
overline: false
|
214
|
+
overline: false,
|
215
|
+
&block
|
207
216
|
)
|
208
217
|
|
209
218
|
len = colours.length
|
@@ -212,6 +221,7 @@ class String
|
|
212
221
|
div = len - 1
|
213
222
|
div_1 = div - 1
|
214
223
|
ret = ''
|
224
|
+
block_given = block_given?
|
215
225
|
|
216
226
|
params = {
|
217
227
|
exclude_spaces: exclude_spaces,
|
@@ -222,7 +232,7 @@ class String
|
|
222
232
|
blink: blink,
|
223
233
|
strikethrough: strikethrough,
|
224
234
|
double_underline: double_underline,
|
225
|
-
overline: overline
|
235
|
+
overline: overline,
|
226
236
|
}
|
227
237
|
|
228
238
|
each_line { |l|
|
@@ -238,7 +248,11 @@ class String
|
|
238
248
|
# colour % len == 0 is very slow approach
|
239
249
|
if counter == len && j < div_1
|
240
250
|
counter, j = 0, j + 1
|
241
|
-
|
251
|
+
if block_given
|
252
|
+
ch.gradient(c[0], c[1], **params, &block)
|
253
|
+
else
|
254
|
+
ret << ch.gradient(c[0], c[1], **params)
|
255
|
+
end
|
242
256
|
|
243
257
|
c.rotate!
|
244
258
|
ch.clear
|
@@ -247,10 +261,14 @@ class String
|
|
247
261
|
ch << x
|
248
262
|
end
|
249
263
|
|
250
|
-
|
264
|
+
if block_given
|
265
|
+
ch.gradient(c[0], c[1], **params, &block)
|
266
|
+
else
|
267
|
+
ret << ch.gradient(c[0], c[1], **params)
|
268
|
+
end
|
251
269
|
}
|
252
270
|
|
253
|
-
ret
|
271
|
+
block_given ? nil : ret
|
254
272
|
end
|
255
273
|
|
256
274
|
private
|