Skip to content
This repository has been archived by the owner on May 19, 2022. It is now read-only.

Commit

Permalink
Include comparable.
Browse files Browse the repository at this point in the history
  • Loading branch information
Robert Jackson committed Jun 1, 2011
1 parent 81564ad commit 5cddc84
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
3 changes: 2 additions & 1 deletion lib/simple_uuid.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ def stamp
module SimpleUUID
# UUID format version 1, as specified in RFC 4122, with jitter in place of the mac address and sequence counter.
class UUID
include Comparable

class InvalidVersion < StandardError #:nodoc:
end
Expand Down Expand Up @@ -133,4 +134,4 @@ def total_usecs
(elements[0] + (elements[1] << 32) + ((elements[2] & 0x0FFF) << 48) - GREGORIAN_EPOCH_OFFSET) / 10
end
end
end
end
11 changes: 10 additions & 1 deletion test/test_uuid.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,13 @@ def test_equality
b = a.dup
assert_equal a, b
end
end

def test_comparison
current_uuid = UUID.new(Time.now)
future_uuid = UUID.new(Time.now + rand(60))

assert current_uuid < future_uuid
assert current_uuid >= current_uuid
assert future_uuid >= current_uuid
end
end

0 comments on commit 5cddc84

Please sign in to comment.