Class: NSNumber

Inherits:
Object show all
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

Instance Method Details

#after(date) ⇒ Object



15
16
17
# File 'lib/cocoa/sugarcube-nsdate/nsnumber.rb', line 15

def after(date)
  date + self
end

#agoObject



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(=nil, &fire)
  NSTimer.scheduledTimerWithTimeInterval(self, target: fire, selector: 'call:', userInfo: , repeats: true)
end

#henceObject



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(=nil, &fire)
  NSTimer.scheduledTimerWithTimeInterval(self, target: fire, selector: 'call:', userInfo: , repeats: false)
end

#nsdateObject



3
4
5
# File 'lib/cocoa/sugarcube-nsdate/nsnumber.rb', line 3

def nsdate
  NSDate.dateWithTimeIntervalSince1970(self)
end

#pixelsObject 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_boolObject



10
11
12
# File 'lib/cocoa/sugarcube-numbers/nsnumber.rb', line 10

def to_bool
  boolValue
end