Class: Fixnum
- Defined in:
- lib/sugarcube-color/fixnum.rb,
lib/sugarcube-nsdate/fixnum.rb,
lib/sugarcube-numbers/fixnum.rb
Instance Method Summary collapse
- #after(date) ⇒ Object
- #ago ⇒ Object
- #before(date) ⇒ Object
- #hence ⇒ Object
- #nstimezone ⇒ Object
- #nth ⇒ Object
- #ordinalize ⇒ Object
-
#uicolor(alpha = nil) ⇒ Object
0xffffff.uicolor 0xffffff.uicolor(0.33) => UIColor.colorWithRed(1.0, green:1.0, blue: 1.0, alpha:1.0) UIColor.colorWithRed(1.0, green:1.0, blue: 1.0, alpha:0.33).
Instance Method Details
#after(date) ⇒ Object
15 16 17 |
# File 'lib/sugarcube-nsdate/fixnum.rb', line 15 def after(date) date + self end |
#ago ⇒ Object
11 12 13 |
# File 'lib/sugarcube-nsdate/fixnum.rb', line 11 def ago self.before(NSDate.new) end |
#before(date) ⇒ Object
7 8 9 |
# File 'lib/sugarcube-nsdate/fixnum.rb', line 7 def before(date) date - self end |
#hence ⇒ Object
19 20 21 |
# File 'lib/sugarcube-nsdate/fixnum.rb', line 19 def hence self.after(NSDate.new) end |
#nstimezone ⇒ Object
3 4 5 |
# File 'lib/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/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/sugarcube-numbers/fixnum.rb', line 21 def ordinalize return "#{self}#{nth}" end |
#uicolor(alpha = nil) ⇒ Object
0xffffff.uicolor 0xffffff.uicolor(0.33) => UIColor.colorWithRed(1.0, green:1.0, blue: 1.0, alpha:1.0) UIColor.colorWithRed(1.0, green:1.0, blue: 1.0, alpha:0.33)
8 9 10 11 12 13 14 15 16 |
# File 'lib/sugarcube-color/fixnum.rb', line 8 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 |