Class: Time

Inherits:
Object
  • Object
show all
Defined in:
lib/acts_as_flux_capacitor/core_class_extensions.rb

Constant Summary collapse

@@approx_eql_tolerance_in_seconds =
2

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.approx_eql_tolerance_in_secondsObject



5
6
7
# File 'lib/acts_as_flux_capacitor/core_class_extensions.rb', line 5

def Time.approx_eql_tolerance_in_seconds
  @@approx_eql_tolerance_in_seconds
end

.approx_eql_tolerance_in_seconds=(seconds) ⇒ Object



9
10
11
# File 'lib/acts_as_flux_capacitor/core_class_extensions.rb', line 9

def Time.approx_eql_tolerance_in_seconds=(seconds)
  @@approx_eql_tolerance_in_seconds = seconds
end

Instance Method Details

#approx_eql?(other_time, tolerance = @@approx_eql_tolerance_in_seconds) ⇒ Boolean

Returns:

  • (Boolean)


13
14
15
16
# File 'lib/acts_as_flux_capacitor/core_class_extensions.rb', line 13

def approx_eql? other_time,tolerance = @@approx_eql_tolerance_in_seconds
  times_to_i = [self,other_time].collect { |time| time.to_i }
  (self - other_time).abs < tolerance
end