color_code 0.3.0 → 0.4.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 63030412515c10648352e99699cad7a3f198967d
4
- data.tar.gz: f16b9030f80f7cbea5c1ee06a8cb97977a40f182
3
+ metadata.gz: b8cd2e12c36266041e9fd1a993b36c76ed8ca234
4
+ data.tar.gz: 9204776608eb4c73a2285169f5515b3757f0eff8
5
5
  SHA512:
6
- metadata.gz: 146ac28ae23934309aa38d3af96fa4e1304509ae0c0d14f3e8e029eeeeb937d42c37e09d007d6e1cde1c490dbea6165aae1c585f6597a914766be2c52e12a86b
7
- data.tar.gz: 60b0573a3819dccbc785d4714a4fb07a35324ae924e83c7a5de38bd89a28bf52f5f40e63f637ccc67d9f0499b86a3af864cbcfedc0ff05247d718d30b3303098
6
+ metadata.gz: 144e2c3bc506c54147260368faf7c947865edf6ad6aee910584fd4756cdcf4a0c9998d48e2dcccec7f9710e030f9cfdbfc8c24612042fc644e99a59633c87edd
7
+ data.tar.gz: e4fda7bf6746e8d232b87ebfc646849c48e46bf26ee7063ce5530af946fe626d15bafe732ac08d0a9343608644d9efa1c96974bc09c1e35cb075ffcc7b77f409
@@ -1,4 +1,5 @@
1
1
  require 'color_code/version'
2
+ require 'color_code/distance'
2
3
  require 'color_code/hue_saturation'
3
4
  require 'color_code/rgb'
4
5
  require 'color_code/hsl'
@@ -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
@@ -1,3 +1,3 @@
1
1
  module ColorCode
2
- VERSION = "0.3.0"
2
+ VERSION = "0.4.0"
3
3
  end
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.3.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-02 00:00:00.000000000 Z
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