string_dot_gradient 0.1.9 → 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
- data/lib/string_dot_gradient/gradient.rb +33 -3
- data/lib/string_dot_gradient/version.rb +1 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 888e756d71707ea2545d43cf8a3fdc38ac9a390570fe7b9e52271c89e7af3d7d
|
4
|
+
data.tar.gz: fc1bf3010fca21e26c7ee07504ad2e76dd66affe2eff5acd6b316ebf2805a243
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c9fce9010dba35978ef9b93e5336911f534b6d37c8635817240414a86411317f32626a6a50c0a52ef8bab7f27f12a7912fbaec572fa200a7b2011c858d8c5c0d
|
7
|
+
data.tar.gz: 9cbf19d2ef2361f1d2bd6cd2ec39ea3e96264617bf5ba0a216c542bc4c401da58a72927095b360a204c0040c6e84d2688328002b0601e628b4eca5e6d9cd2157
|
@@ -46,10 +46,41 @@ class String
|
|
46
46
|
#
|
47
47
|
# The option blink makes the texts blink on supported terminals.
|
48
48
|
# Set blink to anything truthy or falsey, but better just go with true and false or nil
|
49
|
-
def gradient(*arg_colours,
|
49
|
+
def gradient(*arg_colours,
|
50
|
+
exclude_spaces: true,
|
51
|
+
bg: false,
|
52
|
+
bold: false,
|
53
|
+
italic: false,
|
54
|
+
underline: false,
|
55
|
+
blink: false,
|
56
|
+
strikethrough: false,
|
57
|
+
double_underline: false,
|
58
|
+
overline: false
|
59
|
+
)
|
60
|
+
|
50
61
|
temp = ''
|
51
62
|
flatten_colours = arg_colours.flatten
|
52
63
|
|
64
|
+
# Create the styling here rather than creating it in the each_line loop
|
65
|
+
# We also make it a bit different, rather than using \e[1m\e[5m, we will do
|
66
|
+
# \e[1;5m to save the number of characters spit out by this method
|
67
|
+
style = nil
|
68
|
+
|
69
|
+
if bold || italic || underline || blink || strikethrough || double_underline || overline
|
70
|
+
style = "\e["
|
71
|
+
|
72
|
+
style << '1;'.freeze if bold
|
73
|
+
style << '3;'.freeze if italic
|
74
|
+
style << '4;'.freeze if underline
|
75
|
+
style << '5;'.freeze if blink
|
76
|
+
style << '9;'.freeze if strikethrough
|
77
|
+
style << '21;'.freeze if double_underline
|
78
|
+
style << '53;'.freeze if overline
|
79
|
+
|
80
|
+
style.chop!
|
81
|
+
style << ?m.freeze
|
82
|
+
end
|
83
|
+
|
53
84
|
raise ArgumentError, "Wrong numeber of colours (given #{flatten_colours.length}, expected minimum 2)" if flatten_colours.length < 2
|
54
85
|
raise ArgumentError, "Given argument for colour is neither a String nor an Integer" if flatten_colours.any? { |x| !(x.is_a?(String) || x.is_a?(Integer)) }
|
55
86
|
|
@@ -65,8 +96,7 @@ class String
|
|
65
96
|
init = bg ? 48 : 38
|
66
97
|
|
67
98
|
each_line do |c|
|
68
|
-
temp <<
|
69
|
-
temp << "\e[5m".freeze if blink
|
99
|
+
temp << style if style
|
70
100
|
|
71
101
|
_r, _g, _b = r, g, b
|
72
102
|
chomped = !!c.chomp!(''.freeze)
|
metadata
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: string_dot_gradient
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
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-15 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
|
-
description: An itty-bitty extension that adds gradient method to String class that
|
14
|
-
supports any hex colour, for Linux
|
13
|
+
description: An itty-bitty extension that adds "gradient" method to String class that
|
14
|
+
supports any hex colour, for Linux terminals
|
15
15
|
email:
|
16
16
|
- souravgoswami@protonmail.com
|
17
17
|
executables: []
|
@@ -43,6 +43,6 @@ requirements: []
|
|
43
43
|
rubygems_version: 3.1.4
|
44
44
|
signing_key:
|
45
45
|
specification_version: 4
|
46
|
-
summary: An itty-bitty extension that adds gradient method to String class that
|
47
|
-
any hex colour, for Linux
|
46
|
+
summary: An itty-bitty extension that adds "gradient" method to String class that
|
47
|
+
supports any hex colour, for Linux terminals
|
48
48
|
test_files: []
|