Class: Chickadee::UUID
- Inherits:
-
Object
- Object
- Chickadee::UUID
- Defined in:
- lib/chickadee/vos/uuid.rb
Constant Summary collapse
- UUID_REGEX =
/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/
Instance Method Summary collapse
- #==(other) ⇒ Object
- #eql?(other) ⇒ Boolean
- #hash ⇒ Object
-
#initialize(uuid) ⇒ UUID
constructor
A new instance of UUID.
- #to_s ⇒ Object
Constructor Details
#initialize(uuid) ⇒ UUID
Returns a new instance of UUID.
5 6 7 8 |
# File 'lib/chickadee/vos/uuid.rb', line 5 def initialize(uuid) raise(ArgumentError, "invalid uuid: #{uuid}") unless uuid.is_a?(String) && uuid.match(UUID_REGEX) @uuid = uuid end |
Instance Method Details
#==(other) ⇒ Object
14 15 16 |
# File 'lib/chickadee/vos/uuid.rb', line 14 def ==(other) self.class == other.class && self.hash == other.hash end |
#eql?(other) ⇒ Boolean
18 19 20 |
# File 'lib/chickadee/vos/uuid.rb', line 18 def eql?(other) self == other end |
#hash ⇒ Object
22 23 24 |
# File 'lib/chickadee/vos/uuid.rb', line 22 def hash @uuid.hash end |
#to_s ⇒ Object
10 11 12 |
# File 'lib/chickadee/vos/uuid.rb', line 10 def to_s @uuid end |