colos 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/lib/colos/version.rb +1 -1
  3. data/lib/colos.rb +17 -15
  4. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7122294595ee7cada3dcc8fcdcfc938fa0990bd5
4
- data.tar.gz: 17f4022e8eb0110b5633192aa2e481743e6da170
3
+ metadata.gz: 9e5469391dbf237d9e1aad1b3dbf6d6fbc19ce51
4
+ data.tar.gz: d072dfbecb86bda21e8fd9193b56f6cc01b7a4cd
5
5
  SHA512:
6
- metadata.gz: b46a0be11380cb35520335162cac5e528b82ce99859284c2e5f3e3ea3672a5d966a01fda6daad4edd4c1ce94518971de54d5dae5b01f85c60ad99c0669fde758
7
- data.tar.gz: 10960ed5b12baf46e3d0c53cd9368fe935c03dd9d830c6e3d514c6bfac8c4378533391916336480bfcf2a66effd2c3bf36e397e6e80e3318eed2f2d75d114297
6
+ metadata.gz: 003ef69231c3ed95b600c53c6471e960241fa5c12056875849b7949f0ae99ed3af9d3b2817c463f2c507fb4659c70218341231a2d64235e8795d792b49f0d20c
7
+ data.tar.gz: 5e16316371760859c3952ae10075bced588799a8f547855ef3707f19a1b1be8c105c63bf5cba3a5f592ffc86120d8760d6ee7bc6de2d99477e17c62b7b20d2ef
data/lib/colos/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  class Colos
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
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]].map &:to_i
48
+ rgb = ip.permutation(3).to_a[@options[:randomizr]]
49
49
 
50
- rgb.each do |b|
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
- hex = ""
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: colos
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yuri Artemev