4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
# File 'lib/serving_seconds/core.rb', line 4
def humanize(secs, prec = nil, format = nil)
prec, format = format, prec if prec && !prec.is_a?(Numeric)
format ||= :short
prec ||= 0
humanized = []
intervals.each_with_index do |interval, i|
units = send(interval)
next unless secs >= units || units == seconds
return find(secs, i, prec, format) if format == :short
next if secs == 0
secs = add_time_for_interval(humanized, secs, units, i, format)
end
humanized.join ', '
end
|