Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- lib/familia/core_ext.rb
Overview
Extends the String class with time-related functionality
This implementaton assumes Time::Units and Numeric mixins are available.
Direct Known Subclasses
Instance Method Summary collapse
-
#in_seconds ⇒ Float?
Converts a string representation of time to seconds.
Instance Method Details
#in_seconds ⇒ Float?
Converts a string representation of time to seconds
14 15 16 17 18 |
# File 'lib/familia/core_ext.rb', line 14 def in_seconds q, u = scan(/([\d.]+)([smhyd])?/).flatten q &&= q.to_f and u ||= 's' q&.in_seconds(u) end |