colos 0.0.4 → 0.0.5
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/colos/version.rb +1 -1
- data/lib/colos.rb +17 -15
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9e5469391dbf237d9e1aad1b3dbf6d6fbc19ce51
|
4
|
+
data.tar.gz: d072dfbecb86bda21e8fd9193b56f6cc01b7a4cd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 003ef69231c3ed95b600c53c6471e960241fa5c12056875849b7949f0ae99ed3af9d3b2817c463f2c507fb4659c70218341231a2d64235e8795d792b49f0d20c
|
7
|
+
data.tar.gz: 5e16316371760859c3952ae10075bced588799a8f547855ef3707f19a1b1be8c105c63bf5cba3a5f592ffc86120d8760d6ee7bc6de2d99477e17c62b7b20d2ef
|
data/lib/colos/version.rb
CHANGED
data/lib/colos.rb
CHANGED
@@ -45,15 +45,9 @@ class Colos
|
|
45
45
|
|
46
46
|
raise "Invalid IP" unless ip.size == 4
|
47
47
|
|
48
|
-
rgb = ip.permutation(3).to_a[@options[:randomizr]]
|
48
|
+
rgb = ip.permutation(3).to_a[@options[:randomizr]]
|
49
49
|
|
50
|
-
rgb
|
51
|
-
b = b.to_s 16
|
52
|
-
b = "0#{b}" unless b.size == 2
|
53
|
-
hex += b
|
54
|
-
end
|
55
|
-
|
56
|
-
hex
|
50
|
+
hex_from_int rgb
|
57
51
|
end
|
58
52
|
|
59
53
|
# Convert IPv4 to colors
|
@@ -71,13 +65,7 @@ class Colos
|
|
71
65
|
raise "Invalid IP" unless ip.size == 4
|
72
66
|
|
73
67
|
ip.permutation(3).to_a.each do |color|
|
74
|
-
|
75
|
-
color.each do |b|
|
76
|
-
b = b.to_i.to_s 16
|
77
|
-
b = "0#{b}" unless b.size == 2
|
78
|
-
hex += b
|
79
|
-
end
|
80
|
-
hexs << hex
|
68
|
+
hexs << hex_from_int(color)
|
81
69
|
end
|
82
70
|
|
83
71
|
hexs
|
@@ -116,4 +104,18 @@ class Colos
|
|
116
104
|
colors
|
117
105
|
end
|
118
106
|
|
107
|
+
private
|
108
|
+
|
109
|
+
def hex_from_int ints
|
110
|
+
hex = ""
|
111
|
+
|
112
|
+
ints.map(&:to_i).each do |b|
|
113
|
+
b = b.to_s 16
|
114
|
+
b = "0#{b}" unless b.size == 2
|
115
|
+
hex += b
|
116
|
+
end
|
117
|
+
|
118
|
+
hex
|
119
|
+
end
|
120
|
+
|
119
121
|
end
|