color_code 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/color_code.rb +1 -0
- data/lib/color_code/distance.rb +37 -0
- data/lib/color_code/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b8cd2e12c36266041e9fd1a993b36c76ed8ca234
|
4
|
+
data.tar.gz: 9204776608eb4c73a2285169f5515b3757f0eff8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 144e2c3bc506c54147260368faf7c947865edf6ad6aee910584fd4756cdcf4a0c9998d48e2dcccec7f9710e030f9cfdbfc8c24612042fc644e99a59633c87edd
|
7
|
+
data.tar.gz: e4fda7bf6746e8d232b87ebfc646849c48e46bf26ee7063ce5530af946fe626d15bafe732ac08d0a9343608644d9efa1c96974bc09c1e35cb075ffcc7b77f409
|
data/lib/color_code.rb
CHANGED
@@ -0,0 +1,37 @@
|
|
1
|
+
module ColorCode
|
2
|
+
class Distance
|
3
|
+
class << self
|
4
|
+
def results(color)
|
5
|
+
config.colors.inject({}) do |sum, base|
|
6
|
+
sum[base[:id]] = color.distance(base[:color])
|
7
|
+
sum
|
8
|
+
end.sort { |a, b| a[1] <=> b[1] }
|
9
|
+
end
|
10
|
+
|
11
|
+
def min(color)
|
12
|
+
results(color).first
|
13
|
+
end
|
14
|
+
|
15
|
+
def max(color)
|
16
|
+
results(color).last
|
17
|
+
end
|
18
|
+
|
19
|
+
def configure
|
20
|
+
yield config
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
def config
|
25
|
+
@config ||= Config.new
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
class Config
|
30
|
+
attr_accessor :colors
|
31
|
+
|
32
|
+
def initialize
|
33
|
+
@colors = []
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
data/lib/color_code/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: color_code
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- shiro16
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-05-
|
11
|
+
date: 2016-05-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -69,6 +69,7 @@ files:
|
|
69
69
|
- bin/setup
|
70
70
|
- color_code.gemspec
|
71
71
|
- lib/color_code.rb
|
72
|
+
- lib/color_code/distance.rb
|
72
73
|
- lib/color_code/hsl.rb
|
73
74
|
- lib/color_code/hsv.rb
|
74
75
|
- lib/color_code/hue_saturation.rb
|