Sha256: bd605e8b30ed883661a4ae0ee80626777895eb40069f6a2df60883fd8d752b4a

Contents?: true

Size: 794 Bytes

Versions: 4

Compression:

Stored size: 794 Bytes

Contents

class Numeric

  def percent
    self / 100.0
  end

  def seconds
    self
  end
  alias :second :seconds

  def minutes
    self * 60
  end
  alias :minute :minutes

  def hours
    self * 3600
  end
  alias :hour :hours

  def days
    self.hours * 24
  end
  alias :day :days

  def weeks
    self.days * 7
  end
  alias :week :weeks

  def months
    self.days * 30
  end
  alias :month :months

  def years
    self.days * 365
  end
  alias :year :years

  def later(user_info=nil, &fire)
    NSTimer.scheduledTimerWithTimeInterval(self.to_f, target: fire, selector: 'call:', userInfo: user_info, repeats: false)
  end

  def every(user_info=nil, &fire)
    NSTimer.scheduledTimerWithTimeInterval(self.to_f, target: fire, selector: 'call:', userInfo: user_info, repeats: true)
  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
sugarcube-0.7.6 lib/sugarcube/numeric.rb
sugarcube-0.7.4 lib/sugarcube/numeric.rb
sugarcube-0.7.3 lib/sugarcube/numeric.rb
sugarcube-0.7.2 lib/sugarcube/numeric.rb