Module: Metrics::TimeConversion

Included in:
Instruments::Meter, Instruments::Timer
Defined in:
lib/ruby-metrics/time_units.rb

Instance Method Summary collapse

Instance Method Details

#convert_to_ns(value, unit) ⇒ Object



48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/ruby-metrics/time_units.rb', line 48

def convert_to_ns(value, unit)
  units = {
      :nanoseconds            => Nanoseconds,
      :microseconds           => Microseconds,
      :milliseconds           => Milliseconds,
      :seconds                => Seconds,
      :minutes                => Minutes,
      :hours                  => Hours
  }
  
  units[unit].to_nsec * value
end