Class: UIColor
- Defined in:
- lib/sugarcube/uicolor.rb,
lib/sugarcube/to_s/uicolor.rb
Instance Method Summary collapse
- #alpha ⇒ Object
- #blue ⇒ Object
- #cgcolor ⇒ Object
- #green ⇒ Object
- #red ⇒ Object
- #to_s ⇒ Object
- #uicolor ⇒ Object
Instance Method Details
#alpha ⇒ Object
20 21 22 |
# File 'lib/sugarcube/uicolor.rb', line 20 def alpha _sugarcube_colors && _sugarcube_colors[:alpha] end |
#blue ⇒ Object
16 17 18 |
# File 'lib/sugarcube/uicolor.rb', line 16 def blue _sugarcube_colors && _sugarcube_colors[:blue] end |
#cgcolor ⇒ Object
8 9 10 |
# File 'lib/sugarcube/uicolor.rb', line 8 def cgcolor self.CGColor end |
#green ⇒ Object
12 13 14 |
# File 'lib/sugarcube/uicolor.rb', line 12 def green _sugarcube_colors && _sugarcube_colors[:green] end |
#red ⇒ Object
4 5 6 |
# File 'lib/sugarcube/uicolor.rb', line 4 def red _sugarcube_colors && _sugarcube_colors[:red] end |
#to_s ⇒ Object
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/sugarcube/to_s/uicolor.rb', line 2 def to_s system_color = nil Symbol.uicolors.each_pair do |color, method| if UIColor.send(method) == self if self.alpha < 1 system_color = "UIColor.#{method}(#{alpha})" else system_color = "UIColor.#{method}" end break end end return system_color if system_color if self.red && self.green && self.blue red = (self.red * 255).round << 16 green = (self.green * 255).round << 8 blue = (self.blue * 255).round my_color = red + green + blue inside = my_color.to_s(16) inside = '0x' + '0' * (6 - inside.length) Symbol.css_colors.each_pair do |color, hex| if hex == my_color inside = color.inspect break end end if self.alpha < 1 return "UIColor.color(#{inside}, #{alpha})" else return "UIColor.color(#{inside})" end else super end end |
#uicolor ⇒ Object
2 |
# File 'lib/sugarcube/uicolor.rb', line 2 def uicolor ; self ; end |