color_lib 1.4.4 → 1.4.5

Sign up to get free protection for your applications and to get access to all the features.
data/lib/color_lib/rgb.rb CHANGED
@@ -34,17 +34,21 @@ class ColorLib::RGB
34
34
  # ColorLib::RGB.from_html("#cabbed")
35
35
  # ColorLib::RGB.from_html("cabbed")
36
36
  def from_html(html_colour)
37
- html_colour = html_colour.gsub(%r{[#;]}, '')
38
- case html_colour.size
39
- when 3
40
- colours = html_colour.scan(%r{[0-9A-Fa-f]}).map { |el| (el * 2).to_i(16) }
41
- when 6
42
- colours = html_colour.scan(%r<[0-9A-Fa-f]{2}>).map { |el| el.to_i(16) }
37
+ if html_colour.present?
38
+ html_colour = html_colour.gsub(%r{[#;]}, '')
39
+ case html_colour.size
40
+ when 3
41
+ colours = html_colour.scan(%r{[0-9A-Fa-f]}).map { |el| (el * 2).to_i(16) }
42
+ when 6
43
+ colours = html_colour.scan(%r<[0-9A-Fa-f]{2}>).map { |el| el.to_i(16) }
44
+ else
45
+ raise ArgumentError
46
+ end
47
+
48
+ ColorLib::RGB.new(*colours)
43
49
  else
44
50
  raise ArgumentError
45
51
  end
46
-
47
- ColorLib::RGB.new(*colours)
48
52
  end
49
53
  end
50
54
 
@@ -1,3 +1,3 @@
1
1
  module ColorLib
2
- VERSION = "1.4.4"
2
+ VERSION = "1.4.5"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: color_lib
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.4
4
+ version: 1.4.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brandfolder, Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-12-30 00:00:00.000000000 Z
11
+ date: 2015-02-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -129,4 +129,3 @@ test_files:
129
129
  - test/test_monocontrast.rb
130
130
  - test/test_rgb.rb
131
131
  - test/test_yiq.rb
132
- has_rdoc: