Module: RubyUnits::Time::ClassMethods
- Included in:
- Time
- Defined in:
- lib/ruby_units/time.rb
Overview
Class methods for [Time] objects
Instance Method Summary collapse
-
#at(*args, **kwargs) ⇒ ::Time
Convert a duration to a [::Time] object by considering the duration to be the number of seconds since the epoch.
- #in(duration) ⇒ ::Time
Instance Method Details
#at(*args, **kwargs) ⇒ ::Time
Convert a duration to a [::Time] object by considering the duration to be the number of seconds since the epoch
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/ruby_units/time.rb', line 18 def at(*args, **kwargs) case args.first when RubyUnits::Unit = args.last.is_a?(Hash) ? args.pop : kwargs secondary_unit = args[2] || "microsecond" case args[1] when Numeric super((args.first + RubyUnits::Unit.new(args[1], secondary_unit.to_s)).convert_to("second").scalar, **) else super(args.first.convert_to("second").scalar, **) end else super end end |