Class: Fixnum
- Inherits:
-
Object
- Object
- Fixnum
- Defined in:
- lib/sugarcube/fixnum.rb
Instance Method Summary collapse
- #percent ⇒ Object
-
#uicolor(alpha = nil) ⇒ Object
0xffffff.uicolor 0xffffff.uicolor(0.33) => UIColor.colorWithRed(1.0, green:1.0, red: 1.0, alpha:1.0) UIColor.colorWithRed(1.0, green:1.0, red: 1.0, alpha:0.33).
Instance Method Details
#percent ⇒ Object
20 21 22 |
# File 'lib/sugarcube/fixnum.rb', line 20 def percent self.to_f.percent end |
#uicolor(alpha = nil) ⇒ Object
10 11 12 13 14 15 16 17 18 |
# File 'lib/sugarcube/fixnum.rb', line 10 def uicolor(alpha=nil) alpha = 1.0 if alpha.nil? red = ((self & 0xFF0000) >> 16).to_f / 255.0 green = ((self & 0xFF00) >> 8).to_f / 255.0 blue = (self & 0xFF).to_f / 255.0 UIColor.colorWithRed(red, green:green, blue:blue, alpha:alpha.to_f) end |