Class: ParameterSubstitution::Formatters::DurationGroupedByDescription
- Inherits:
-
Base
- Object
- Base
- ParameterSubstitution::Formatters::DurationGroupedByDescription
show all
- Defined in:
- lib/parameter_substitution/formatters/duration_grouped_by_description.rb
Constant Summary
collapse
- DURATION_DESCRIPTIONS =
[
[30.seconds, "<30sec"],
[60.seconds, "30-60sec"],
[5.minutes, "1-5min"],
[10.minutes, "5-10min"],
[20.minutes, "10-20min"],
[30.minutes, "20-30min"],
[60.minutes, "30-60min"],
[nil, ">60min"]
].freeze
Class Method Summary
collapse
Methods inherited from Base
encoding, has_parameters?, key, parse_duration
Class Method Details
.description ⇒ Object
15
16
17
|
# File 'lib/parameter_substitution/formatters/duration_grouped_by_description.rb', line 15
def self.description
"Converts a duration in seconds into one of the following: #{DURATION_DESCRIPTIONS.map(&:last).join(',')}"
end
|
19
20
21
22
|
# File 'lib/parameter_substitution/formatters/duration_grouped_by_description.rb', line 19
def self.format(duration)
fixed_duration = parse_duration(duration)
DURATION_DESCRIPTIONS.find { |max_duration, _description| !max_duration || fixed_duration.to_i < max_duration }.last
end
|