Class: Numeric
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
- #ago(time = Time.now) ⇒ Object (also: #until)
- #days ⇒ Object (also: #day)
- #hours ⇒ Object (also: #hour)
- #minutes ⇒ Object (also: #minute)
- #seconds ⇒ Object (also: #second)
- #since(time = Time.now) ⇒ Object (also: #from_now)
- #weeks ⇒ Object (also: #week)
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 |
#days ⇒ Object Also known as: day
32 33 34 |
# File 'lib/core/time.rb', line 32 def days self * 24.hours end |
#hours ⇒ Object Also known as: hour
27 28 29 |
# File 'lib/core/time.rb', line 27 def hours self * 60.minutes end |
#minutes ⇒ Object Also known as: minute
22 23 24 |
# File 'lib/core/time.rb', line 22 def minutes self * 60 end |
#seconds ⇒ Object 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 |
#weeks ⇒ Object Also known as: week
37 38 39 |
# File 'lib/core/time.rb', line 37 def weeks self * 7.days end |