colos 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/colos/version.rb +1 -1
- data/lib/colos.rb +5 -3
- 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: 7122294595ee7cada3dcc8fcdcfc938fa0990bd5
|
4
|
+
data.tar.gz: 17f4022e8eb0110b5633192aa2e481743e6da170
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b46a0be11380cb35520335162cac5e528b82ce99859284c2e5f3e3ea3672a5d966a01fda6daad4edd4c1ce94518971de54d5dae5b01f85c60ad99c0669fde758
|
7
|
+
data.tar.gz: 10960ed5b12baf46e3d0c53cd9368fe935c03dd9d830c6e3d514c6bfac8c4378533391916336480bfcf2a66effd2c3bf36e397e6e80e3318eed2f2d75d114297
|
data/lib/colos/version.rb
CHANGED
data/lib/colos.rb
CHANGED
@@ -8,7 +8,7 @@ class Colos
|
|
8
8
|
# Initializer
|
9
9
|
#
|
10
10
|
# Example:
|
11
|
-
# >> Colos.new frequency: 1.2, randomizr: 12
|
11
|
+
# >> Colos.new frequency: 1.2, randomizr: 12, format: :hex
|
12
12
|
# => Colos instance
|
13
13
|
#
|
14
14
|
# Arguments:
|
@@ -17,7 +17,8 @@ class Colos
|
|
17
17
|
default_options = {
|
18
18
|
hash: CityHash,
|
19
19
|
frequency: 1.4,
|
20
|
-
randomizr: 0
|
20
|
+
randomizr: 0,
|
21
|
+
format: :hex
|
21
22
|
}
|
22
23
|
|
23
24
|
# merge
|
@@ -27,6 +28,7 @@ class Colos
|
|
27
28
|
raise "Frequency option should be from 1.2 to 1.6" unless (1.2..1.6).include? @options[:frequency]
|
28
29
|
raise "Randomizr option should be from 0 to 23" unless (0..23).include? @options[:randomizr]
|
29
30
|
raise "Hash class should have `new` method" unless @options[:hash].respond_to?('hash32')
|
31
|
+
raise "Format can be hex or rgb" unless [:hex, :rgb].include? @options[:format]
|
30
32
|
end
|
31
33
|
|
32
34
|
# Convert IPv4 to color
|
@@ -72,7 +74,7 @@ class Colos
|
|
72
74
|
hex = ""
|
73
75
|
color.each do |b|
|
74
76
|
b = b.to_i.to_s 16
|
75
|
-
b
|
77
|
+
b = "0#{b}" unless b.size == 2
|
76
78
|
hex += b
|
77
79
|
end
|
78
80
|
hexs << hex
|