Class: Numeric

Inherits:
Object
  • Object
show all
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

Instance Method Details

#dayObject

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

#daysObject

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

#hourObject

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

#hoursObject

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

#minuteObject

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

#minutesObject

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

#secondObject

Number of seconds (singular form).



40
41
42
# File 'lib/duration/numeric.rb', line 40

def second
  to_i
end

#secondsObject

Number of seconds (equivalent to Numeric#to_i)



15
16
17
# File 'lib/duration/numeric.rb', line 15

def seconds
  to_i
end

#weekObject

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