sugarcube 0.13.2 → 0.13.3

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.
@@ -13,23 +13,29 @@ class UIColor
13
13
  end
14
14
  return system_color if system_color
15
15
 
16
- red = (self.red * 255).round << 16
17
- green = (self.green * 255).round << 8
18
- blue = (self.blue * 255).round
19
- my_color = red + green + blue
16
+ if self.red && self.green && self.blue
17
+ red = (self.red * 255).round << 16
18
+ green = (self.green * 255).round << 8
19
+ blue = (self.blue * 255).round
20
+ my_color = red + green + blue
20
21
 
21
- inside = "0x#{my_color.to_s(16)}"
22
- Symbol.css_colors.each_pair do |color, hex|
23
- if hex == my_color
24
- inside = color.inspect
25
- break
22
+ inside = my_color.to_s(16)
23
+ inside = '0x' + '0' * (6 - inside.length)
24
+
25
+ Symbol.css_colors.each_pair do |color, hex|
26
+ if hex == my_color
27
+ inside = color.inspect
28
+ break
29
+ end
26
30
  end
27
- end
28
31
 
29
- if self.alpha < 1
30
- return "UIColor.color(#{inside}, #{alpha})"
32
+ if self.alpha < 1
33
+ return "UIColor.color(#{inside}, #{alpha})"
34
+ else
35
+ return "UIColor.color(#{inside})"
36
+ end
31
37
  else
32
- return "UIColor.color(#{inside})"
38
+ super
33
39
  end
34
40
  end
35
41
  end
@@ -2,7 +2,7 @@ class UIColor
2
2
  def uicolor ; self ; end
3
3
 
4
4
  def red
5
- _sugarcube_colors[:red]
5
+ _sugarcube_colors && _sugarcube_colors[:red]
6
6
  end
7
7
 
8
8
  def cgcolor
@@ -10,15 +10,15 @@ class UIColor
10
10
  end
11
11
 
12
12
  def green
13
- _sugarcube_colors[:green]
13
+ _sugarcube_colors && _sugarcube_colors[:green]
14
14
  end
15
15
 
16
16
  def blue
17
- _sugarcube_colors[:blue]
17
+ _sugarcube_colors && _sugarcube_colors[:blue]
18
18
  end
19
19
 
20
20
  def alpha
21
- _sugarcube_colors[:alpha]
21
+ _sugarcube_colors && _sugarcube_colors[:alpha]
22
22
  end
23
23
 
24
24
  private
@@ -43,6 +43,8 @@ private
43
43
  blue: white[0],
44
44
  alpha: alpha[0],
45
45
  }
46
+ else
47
+ nil
46
48
  end
47
49
  end
48
50
  end
@@ -1,3 +1,3 @@
1
1
  module SugarCube
2
- Version = '0.13.2'
2
+ Version = '0.13.3'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sugarcube
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.13.2
4
+ version: 0.13.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: