Class: Whenever::NumericSeconds
- Inherits:
-
Object
- Object
- Whenever::NumericSeconds
- Defined in:
- lib/whenever/numeric_seconds.rb
Instance Attribute Summary collapse
-
#number ⇒ Object
readonly
Returns the value of attribute number.
Class Method Summary collapse
Instance Method Summary collapse
- #days ⇒ Object (also: #day)
- #hours ⇒ Object (also: #hour)
-
#initialize(number) ⇒ NumericSeconds
constructor
A new instance of NumericSeconds.
- #minutes ⇒ Object (also: #minute)
- #months ⇒ Object (also: #month)
- #seconds ⇒ Object (also: #second)
- #weeks ⇒ Object (also: #week)
- #years ⇒ Object (also: #year)
Constructor Details
#initialize(number) ⇒ NumericSeconds
Returns a new instance of NumericSeconds.
9 10 11 |
# File 'lib/whenever/numeric_seconds.rb', line 9 def initialize(number) @number = number.to_i end |
Instance Attribute Details
#number ⇒ Object (readonly)
Returns the value of attribute number.
3 4 5 |
# File 'lib/whenever/numeric_seconds.rb', line 3 def number @number end |
Class Method Details
.seconds(number, units) ⇒ Object
5 6 7 |
# File 'lib/whenever/numeric_seconds.rb', line 5 def self.seconds(number, units) new(number).send(units) end |
Instance Method Details
#days ⇒ Object Also known as: day
28 29 30 |
# File 'lib/whenever/numeric_seconds.rb', line 28 def days number * 86_400 end |
#hours ⇒ Object Also known as: hour
23 24 25 |
# File 'lib/whenever/numeric_seconds.rb', line 23 def hours number * 3_600 end |
#minutes ⇒ Object Also known as: minute
18 19 20 |
# File 'lib/whenever/numeric_seconds.rb', line 18 def minutes number * 60 end |
#months ⇒ Object Also known as: month
38 39 40 |
# File 'lib/whenever/numeric_seconds.rb', line 38 def months number * 2_592_000 end |
#seconds ⇒ Object Also known as: second
13 14 15 |
# File 'lib/whenever/numeric_seconds.rb', line 13 def seconds number end |
#weeks ⇒ Object Also known as: week
33 34 35 |
# File 'lib/whenever/numeric_seconds.rb', line 33 def weeks number * 604_800 end |
#years ⇒ Object Also known as: year
43 44 45 |
# File 'lib/whenever/numeric_seconds.rb', line 43 def years number * 31_557_600 end |