Module: Kernel
- Defined in:
- lib/uuid.rb
Class Method Summary collapse
-
.UUID(uuid) ⇒ Object
Cast to UUID.
Class Method Details
.UUID(uuid) ⇒ Object
Cast to UUID
5 6 7 8 9 10 11 12 13 |
# File 'lib/uuid.rb', line 5 def UUID(uuid) if uuid.nil? then UUID::NIL elsif uuid.is_a?(UUID) then uuid elsif uuid.is_a?(Integer) then UUID.new(uuid) elsif uuid = String.try_convert(uuid) then uuid.size == 16 ? UUID.new(uuid) : UUID.parse(uuid) else raise TypeError, "can't convert #{uuid.class} into UUID" end end |