Sha256: 88be3958e7016945037ec51dcf177ba8192bcff015d16517b1995fa40dfc9446

Contents?: true

Size: 1.16 KB

Versions: 25

Compression:

Stored size: 1.16 KB

Contents

class Numeric
  def milliseconds
    self / 1000.0
  end
  alias millisecond milliseconds
  alias millisecs milliseconds
  alias millisec milliseconds

  def seconds
    self
  end
  alias second seconds
  alias sec seconds
  alias secs seconds

  def minutes
    self * 60
  end
  alias minute minutes
  alias min minutes
  alias mins 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, target: fire, selector: 'call:', userInfo: user_info, repeats: false)
  end

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


module SugarCube
  module Timer
    module_function

    def every(time, user_info=nil, &fire)
      time.every user_info, &fire
    end

    def after(time, user_info=nil, &fire)
      time.later user_info, &fire
    end
  end
end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
sugarcube-0.18.9 lib/sugarcube/timer.rb
sugarcube-0.18.8 lib/sugarcube/timer.rb
sugarcube-0.18.7 lib/sugarcube/timer.rb
sugarcube-0.18.6 lib/sugarcube/timer.rb
sugarcube-0.18.5 lib/sugarcube/timer.rb
sugarcube-0.18.4 lib/sugarcube/timer.rb
sugarcube-0.18.3 lib/sugarcube/timer.rb
sugarcube-0.18.2 lib/sugarcube/timer.rb
sugarcube-0.18.1 lib/sugarcube/timer.rb
sugarcube-0.18.0 lib/sugarcube/timer.rb
sugarcube-0.16.9 lib/sugarcube/timer.rb
sugarcube-0.16.5 lib/sugarcube/timer.rb
sugarcube-0.16.2 lib/sugarcube/timer.rb
sugarcube-0.16 lib/sugarcube/timer.rb
sugarcube-0.15.5 lib/sugarcube/timer.rb
sugarcube-0.15.3 lib/sugarcube/timer.rb
sugarcube-0.15.0 lib/sugarcube/timer.rb
sugarcube-0.14.0 lib/sugarcube/timer.rb
sugarcube-0.13.7 lib/sugarcube/timer.rb
sugarcube-0.13.5 lib/sugarcube/timer.rb