Class: Time

Inherits:
Object show all
Defined in:
lib/eymiha.rb

Overview

Provides a determination of the precision of Ruby Time values

Constant Summary collapse

@@subsecond_precision =
nil

Class Method Summary collapse

Class Method Details

.subsecond_precisionObject

Returns the actual number of digits of precision of less-than-second values.



123
124
125
126
127
128
129
130
# File 'lib/eymiha.rb', line 123

def self.subsecond_precision
  @@subsecond_precision ||=
    (1..10).collect {
      sleep 0.001001
      s = "#{Time.now.usec}"
      s.length - (/[1-9]/ =~ s.reverse)
    }.max
end