Class: Lite::Measurements::Time
- Includes:
- Helpers::ShiftHelper
- Defined in:
- lib/lite/measurements/time.rb
Constant Summary collapse
- TIME_UNITS =
{ milliseconds: 0.001, seconds: 1.0, minutes: 60.0, hours: 3600.0, days: 86_400.0, weeks: 604_800.0, years: 31_557_600.0, decades: 31_557_600.0 * 10.0, centuries: 31_557_600.0 * 100.0, millenniums: 31_557_600.0 * 1_000.0 }.freeze
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
Methods inherited from Base
Constructor Details
This class inherits a constructor from Lite::Measurements::Base
Instance Method Details
#convert(from:, to:) ⇒ Object
22 23 24 25 26 27 |
# File 'lib/lite/measurements/time.rb', line 22 def convert(from:, to:) assert_all_valid_keys!(from, to, TIME_UNITS.keys) return amount if equal_units?(from, to) shift_units(amount, type: TIME_UNITS, from: from, to: to) end |