Class: Numeric
- Inherits:
-
Object
- Object
- Numeric
- Defined in:
- lib/duration/numeric.rb
Overview
Additional methods added to numeric objects allow the developer to construct a calculated number of seconds through human-readable methods.
60.seconds #=> 60
60.minutes #=> 3600
... and so on
Singular methods are also defined.
1.minute #=> 60
1.hour #=> 3600
... and so on
Instance Method Summary collapse
-
#day ⇒ Object
Number of seconds using the number as the base of days (singular form).
-
#days ⇒ Object
Number of seconds using the number as the base of days.
-
#hour ⇒ Object
Number of seconds using the number as the base of hours (singular form).
-
#hours ⇒ Object
Number of seconds using the number as the base of hours.
-
#minute ⇒ Object
Number of seconds using the number as the base of minutes (singular form).
-
#minutes ⇒ Object
Number of seconds using the number as the base of minutes.
-
#second ⇒ Object
Number of seconds (singular form).
-
#seconds ⇒ Object
Number of seconds (equivalent to Numeric#to_i).
-
#week ⇒ Object
Number of seconds using the number as the base of weeks (singular form).
Instance Method Details
#day ⇒ Object
Number of seconds using the number as the base of days (singular form).
55 56 57 |
# File 'lib/duration/numeric.rb', line 55 def day to_i * 86400 end |
#days ⇒ Object
Number of seconds using the number as the base of days.
30 31 32 |
# File 'lib/duration/numeric.rb', line 30 def days to_i * 86400 end |
#hour ⇒ Object
Number of seconds using the number as the base of hours (singular form).
50 51 52 |
# File 'lib/duration/numeric.rb', line 50 def hour to_i * 3600 end |
#hours ⇒ Object
Number of seconds using the number as the base of hours.
25 26 27 |
# File 'lib/duration/numeric.rb', line 25 def hours to_i * 3600 end |
#minute ⇒ Object
Number of seconds using the number as the base of minutes (singular form).
45 46 47 |
# File 'lib/duration/numeric.rb', line 45 def minute to_i * 60 end |
#minutes ⇒ Object
Number of seconds using the number as the base of minutes.
20 21 22 |
# File 'lib/duration/numeric.rb', line 20 def minutes to_i * 60 end |
#second ⇒ Object
Number of seconds (singular form).
40 41 42 |
# File 'lib/duration/numeric.rb', line 40 def second to_i end |
#seconds ⇒ Object
Number of seconds (equivalent to Numeric#to_i)
15 16 17 |
# File 'lib/duration/numeric.rb', line 15 def seconds to_i end |
#week ⇒ Object
Number of seconds using the number as the base of weeks (singular form).
35 36 37 |
# File 'lib/duration/numeric.rb', line 35 def week to_i * 604800 end |