Skip to content

Instantly share code, notes, and snippets.

@jodosha
Created July 12, 2010 14:45
Show Gist options
  • Save jodosha/472552 to your computer and use it in GitHub Desktop.
Save jodosha/472552 to your computer and use it in GitHub Desktop.
# This module is intended for test usage, it helps to compare Time instances with millisecond precision.
# Ruby has a fine-grained internal representation of Time values, so if you try:
# Time.now == Time.now # => false
# By including this module the above comparison returns true.
module ComparableWithFixnum
def self.included(base)
base.class_eval do
alias :"original_==" :==
end
end
def ==(other)
if other.kind_of?(self.class)
self.to_i == other.to_i
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment