Module: Familia::Refinements::TimeLiterals::StringMethods
- Defined in:
- lib/familia/refinements/time_literals.rb
Instance Method Summary collapse
-
#in_seconds ⇒ Float?
Converts string time representation to seconds.
Instance Method Details
#in_seconds ⇒ Float?
Converts string time representation to seconds
271 272 273 274 275 276 277 278 |
# File 'lib/familia/refinements/time_literals.rb', line 271 def in_seconds quantity, unit = scan(/([\d.]+)([a-zA-Zμs]+)?/).flatten return nil unless quantity quantity = quantity.to_f unit ||= 's' TimeLiterals.convert_to_seconds(quantity, unit) end |