Class: Numeric

Inherits:
Object show all
Defined in:
lib/core/time.rb

Overview

Based off the rails Numeric class.

Gives us the ability to use nice phrases such as
30.seconds, 5.days, etc.

Instance Method Summary collapse

Instance Method Details

#ago(time = Time.now) ⇒ Object Also known as: until



7
8
9
# File 'lib/core/time.rb', line 7

def ago(time = Time.now)
  time - self
end

#daysObject Also known as: day



32
33
34
# File 'lib/core/time.rb', line 32

def days
  self * 24.hours
end

#hoursObject Also known as: hour



27
28
29
# File 'lib/core/time.rb', line 27

def hours
  self * 60.minutes
end

#minutesObject Also known as: minute



22
23
24
# File 'lib/core/time.rb', line 22

def minutes
  self * 60
end

#secondsObject Also known as: second



17
18
19
# File 'lib/core/time.rb', line 17

def seconds
  self
end

#since(time = Time.now) ⇒ Object Also known as: from_now



12
13
14
# File 'lib/core/time.rb', line 12

def since(time = Time.now)
  time + self
end

#weeksObject Also known as: week



37
38
39
# File 'lib/core/time.rb', line 37

def weeks
  self * 7.days
end