Module: TimeConstantMethods
- Included in:
- Numeric
- Defined in:
- lib/rdoc/generator/starkfish.rb
Overview
Time constants
Instance Method Summary collapse
-
#after(time) ⇒ Object
Returns the Time <receiver> number of seconds after the given
time. -
#ago ⇒ Object
Returns the Time <receiver> number of seconds ago.
-
#before(time) ⇒ Object
Returns the Time <receiver> number of seconds before the specified
time. -
#days ⇒ Object
(also: #day)
Returns the number of seconds in <receiver> days.
-
#fortnights ⇒ Object
(also: #fortnight)
Returns the number of seconds in <receiver> fortnights.
-
#from_now ⇒ Object
Reads best without arguments: 10.minutes.from_now.
-
#hours ⇒ Object
(also: #hour)
Returns the number of seconds in <receiver> hours.
-
#minutes ⇒ Object
(also: #minute)
Returns number of seconds in <receiver> minutes.
-
#months ⇒ Object
(also: #month)
Returns the number of seconds in <receiver> months (approximate).
-
#seconds ⇒ Object
(also: #second)
Number of seconds (returns receiver unmodified).
-
#weeks ⇒ Object
(also: #week)
Return the number of seconds in <receiver> weeks.
-
#years ⇒ Object
(also: #year)
Returns the number of seconds in <receiver> years (approximate).
Instance Method Details
#after(time) ⇒ Object
Returns the Time <receiver> number of seconds after the given time. E.g., 10.minutes.after( header.expiration )
508 509 510 |
# File 'lib/rdoc/generator/starkfish.rb', line 508 def after( time ) return time + self end |
#ago ⇒ Object
Returns the Time <receiver> number of seconds ago. (e.g., expiration > 2.hours.ago )
501 502 503 |
# File 'lib/rdoc/generator/starkfish.rb', line 501 def ago return self.before( ::Time.now ) end |
#before(time) ⇒ Object
Returns the Time <receiver> number of seconds before the specified time. E.g., 2.hours.before( header.expiration )
494 495 496 |
# File 'lib/rdoc/generator/starkfish.rb', line 494 def before( time ) return time - self end |
#days ⇒ Object Also known as: day
Returns the number of seconds in <receiver> days
462 463 464 |
# File 'lib/rdoc/generator/starkfish.rb', line 462 def days return self * 24.hours end |
#fortnights ⇒ Object Also known as: fortnight
Returns the number of seconds in <receiver> fortnights
474 475 476 |
# File 'lib/rdoc/generator/starkfish.rb', line 474 def fortnights return self * 2.weeks end |
#from_now ⇒ Object
Reads best without arguments: 10.minutes.from_now
513 514 515 |
# File 'lib/rdoc/generator/starkfish.rb', line 513 def from_now return self.after( ::Time.now ) end |
#hours ⇒ Object Also known as: hour
Returns the number of seconds in <receiver> hours
456 457 458 |
# File 'lib/rdoc/generator/starkfish.rb', line 456 def hours return self * 60.minutes end |
#minutes ⇒ Object Also known as: minute
Returns number of seconds in <receiver> minutes
450 451 452 |
# File 'lib/rdoc/generator/starkfish.rb', line 450 def minutes return self * 60 end |
#months ⇒ Object Also known as: month
Returns the number of seconds in <receiver> months (approximate)
480 481 482 |
# File 'lib/rdoc/generator/starkfish.rb', line 480 def months return self * 30.days end |
#seconds ⇒ Object Also known as: second
Number of seconds (returns receiver unmodified)
444 445 446 |
# File 'lib/rdoc/generator/starkfish.rb', line 444 def seconds return self end |
#weeks ⇒ Object Also known as: week
Return the number of seconds in <receiver> weeks
468 469 470 |
# File 'lib/rdoc/generator/starkfish.rb', line 468 def weeks return self * 7.days end |
#years ⇒ Object Also known as: year
Returns the number of seconds in <receiver> years (approximate)
486 487 488 |
# File 'lib/rdoc/generator/starkfish.rb', line 486 def years return (self * 365.25.days).to_i end |