Class: NSNumber
- Defined in:
- lib/cocoa/sugarcube-timer/timer.rb,
lib/ios/sugarcube-numbers/nsnumber.rb,
lib/osx/sugarcube-numbers/nsnumber.rb,
lib/cocoa/sugarcube-nsdate/nsnumber.rb,
lib/cocoa/sugarcube-numbers/nsnumber.rb
Instance Method Summary collapse
- #after(date) ⇒ Object
- #ago ⇒ Object
- #before(date) ⇒ Object
- #every(user_info = nil, &fire) ⇒ Object
- #hence ⇒ Object
- #later(user_info = nil, &fire) ⇒ Object
- #nsdate ⇒ Object
-
#pixels ⇒ Object
(also: #pixel)
Uses the screen scale to determine how many pixels (converts “pixels” to “points”).
- #string_with_style(style = NSNumberFormatterDecimalStyle) ⇒ Object
- #to_bool ⇒ Object
Instance Method Details
#after(date) ⇒ Object
15 16 17 |
# File 'lib/cocoa/sugarcube-nsdate/nsnumber.rb', line 15 def after(date) date + self end |
#ago ⇒ Object
11 12 13 |
# File 'lib/cocoa/sugarcube-nsdate/nsnumber.rb', line 11 def ago self.before(NSDate.new) end |
#before(date) ⇒ Object
7 8 9 |
# File 'lib/cocoa/sugarcube-nsdate/nsnumber.rb', line 7 def before(date) date - self end |
#every(user_info = nil, &fire) ⇒ Object
7 8 9 |
# File 'lib/cocoa/sugarcube-timer/timer.rb', line 7 def every(user_info=nil, &fire) NSTimer.scheduledTimerWithTimeInterval(self, target: fire, selector: 'call:', userInfo: user_info, repeats: true) end |
#hence ⇒ Object
19 20 21 |
# File 'lib/cocoa/sugarcube-nsdate/nsnumber.rb', line 19 def hence self.after(NSDate.new) end |
#later(user_info = nil, &fire) ⇒ Object
3 4 5 |
# File 'lib/cocoa/sugarcube-timer/timer.rb', line 3 def later(user_info=nil, &fire) NSTimer.scheduledTimerWithTimeInterval(self, target: fire, selector: 'call:', userInfo: user_info, repeats: false) end |
#nsdate ⇒ Object
3 4 5 |
# File 'lib/cocoa/sugarcube-nsdate/nsnumber.rb', line 3 def nsdate NSDate.dateWithTimeIntervalSince1970(self) end |
#pixels ⇒ Object Also known as: pixel
Uses the screen scale to determine how many pixels (converts “pixels” to “points”)
9 10 11 |
# File 'lib/ios/sugarcube-numbers/nsnumber.rb', line 9 def pixels self.to_f / UIScreen.mainScreen.scale end |
#string_with_style(style = NSNumberFormatterDecimalStyle) ⇒ Object
3 4 5 6 7 8 |
# File 'lib/cocoa/sugarcube-numbers/nsnumber.rb', line 3 def string_with_style(style=NSNumberFormatterDecimalStyle) if style.respond_to?(:nsnumberstyle) style = style.nsnumberstyle end NSNumberFormatter.localizedStringFromNumber(self, numberStyle:style) end |
#to_bool ⇒ Object
10 11 12 |
# File 'lib/cocoa/sugarcube-numbers/nsnumber.rb', line 10 def to_bool boolValue end |