Class: Fixnum
- Defined in:
- lib/ios/sugarcube-color/fixnum.rb,
lib/osx/sugarcube-color/fixnum.rb,
lib/all/sugarcube-numbers/fixnum.rb,
lib/cocoa/sugarcube-nsdate/fixnum.rb
Instance Method Summary collapse
- #cgcolor(alpha = nil) ⇒ Object
-
#nscolor(alpha = nil) ⇒ Object
0xffeedd.nscolor => NSColor.colorWithRed(0xFF / 255.0, green: 0xEE / 255.0, blue: 0xDD / 255.0, alpha: 1.0) # ≈ NSColor.colorWithRed(1.0, green: 0.933, blue: 0.867, alpha: 1.0).
- #nstimezone ⇒ Object
- #nth ⇒ Object
- #ordinalize ⇒ Object
- #skcolor(alpha = nil) ⇒ Object
-
#uicolor(alpha = nil) ⇒ Object
0xffeedd.uicolor => UIColor.colorWithRed(0xFF / 255.0, green: 0xEE / 255.0, blue: 0xDD / 255.0, alpha: 1.0) # ≈ UIColor.colorWithRed(1.0, green: 0.933, blue: 0.867, alpha: 1.0).
Instance Method Details
#cgcolor(alpha = nil) ⇒ Object
22 23 24 |
# File 'lib/ios/sugarcube-color/fixnum.rb', line 22 def cgcolor(alpha=nil) uicolor(alpha).CGColor end |
#nscolor(alpha = nil) ⇒ Object
0xffeedd.nscolor
>
NSColor.colorWithRed(0xFF / 255.0, green: 0xEE / 255.0, blue: 0xDD / 255.0, alpha: 1.0)
# ≈ NSColor.colorWithRed(1.0, green: 0.933, blue: 0.867, alpha: 1.0)
0xffeedd.nscolor(0.25)
>
NSColor.colorWithRed(0xFF / 255.0, green: 0xEE / 255.0, blue: 0xDD / 255.0, alpha: 0.25)
# ≈ NSColor.colorWithRed(1.0, green: 0.933, blue: 0.867, alpha: 0.25)
12 13 14 15 16 17 18 19 20 |
# File 'lib/osx/sugarcube-color/fixnum.rb', line 12 def nscolor(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 NSColor.rgba(red, green, blue, alpha.to_f) end |
#nstimezone ⇒ Object
3 4 5 |
# File 'lib/cocoa/sugarcube-nsdate/fixnum.rb', line 3 def nstimezone NSTimeZone.timeZoneForSecondsFromGMT(self) end |
#nth ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/all/sugarcube-numbers/fixnum.rb', line 3 def nth # if the first two digits of rank are between 11 and 20, it's an # 'up-teenth' kinda number modulo_100 = self % 100 if modulo_100 < 10 || modulo_100 > 20 case self % 10 when 1 return 'st' when 2 return 'nd' when 3 return 'rd' end end return "th" end |
#ordinalize ⇒ Object
21 22 23 |
# File 'lib/all/sugarcube-numbers/fixnum.rb', line 21 def ordinalize return "#{self}#{nth}" end |
#skcolor(alpha = nil) ⇒ Object
26 27 28 |
# File 'lib/ios/sugarcube-color/fixnum.rb', line 26 def skcolor(alpha=nil) uicolor(alpha) end |
#uicolor(alpha = nil) ⇒ Object
0xffeedd.uicolor
>
UIColor.colorWithRed(0xFF / 255.0, green: 0xEE / 255.0, blue: 0xDD / 255.0, alpha: 1.0)
# ≈ UIColor.colorWithRed(1.0, green: 0.933, blue: 0.867, alpha: 1.0)
0xffeedd.uicolor(0.25)
>
UIColor.colorWithRed(0xFF / 255.0, green: 0xEE / 255.0, blue: 0xDD / 255.0, alpha: 0.25)
# ≈ UIColor.colorWithRed(1.0, green: 0.933, blue: 0.867, alpha: 0.25)
12 13 14 15 16 17 18 19 20 |
# File 'lib/ios/sugarcube-color/fixnum.rb', line 12 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 |