Module: Flaky::AgeParser
- Defined in:
- lib/flaky/age_parser.rb
Class Method Summary collapse
-
.to_seconds(age) ⇒ Object
Parses a human-friendly age string (“24h”, “7d”, “30m”) into seconds.
Class Method Details
.to_seconds(age) ⇒ Object
Parses a human-friendly age string (“24h”, “7d”, “30m”) into seconds. Returns 86400 (24h) for unrecognized formats.
7 8 9 10 11 12 13 14 |
# File 'lib/flaky/age_parser.rb', line 7 def self.to_seconds(age) case age.to_s when /\A(\d+)h\z/ then $1.to_i * 3600 when /\A(\d+)d\z/ then $1.to_i * 86400 when /\A(\d+)m\z/ then $1.to_i * 60 else 86400 end end |