Module: Nostrb::Seconds
Instance Method Summary collapse
- #days(i) ⇒ Object
- #hours(i) ⇒ Object
- #milliseconds(i) ⇒ Object
- #minutes(i) ⇒ Object
- #months(i) ⇒ Object
- #process(hsh) ⇒ Object
- #seconds(i) ⇒ Object
- #weeks(i) ⇒ Object
- #years(i) ⇒ Object
Instance Method Details
#days(i) ⇒ Object
7 |
# File 'lib/nostrb/filter.rb', line 7 def days(i) = 24 * hours(i) |
#hours(i) ⇒ Object
6 |
# File 'lib/nostrb/filter.rb', line 6 def hours(i) = 60 * minutes(i) |
#milliseconds(i) ⇒ Object
3 |
# File 'lib/nostrb/filter.rb', line 3 def milliseconds(i) = i / 1000r |
#minutes(i) ⇒ Object
5 |
# File 'lib/nostrb/filter.rb', line 5 def minutes(i) = 60 * i |
#months(i) ⇒ Object
9 |
# File 'lib/nostrb/filter.rb', line 9 def months(i) = years(i) / 12 |
#process(hsh) ⇒ Object
12 13 14 15 16 17 18 |
# File 'lib/nostrb/filter.rb', line 12 def process(hsh) seconds = 0 [:seconds, :minutes, :hours, :days, :weeks, :months, :years].each { |p| seconds += send(p, hsh[p]) if hsh.key?(p) } seconds end |
#seconds(i) ⇒ Object
4 |
# File 'lib/nostrb/filter.rb', line 4 def seconds(i) = i |
#weeks(i) ⇒ Object
8 |
# File 'lib/nostrb/filter.rb', line 8 def weeks(i) = 7 * days(i) |
#years(i) ⇒ Object
10 |
# File 'lib/nostrb/filter.rb', line 10 def years(i) = 365 * days(i) |