Class: UUID4::Formatter::Compact
- Inherits:
-
Object
- Object
- UUID4::Formatter::Compact
- Defined in:
- lib/uuid4/formatter/compact.rb
Constant Summary collapse
- REGEXP =
/^[\da-f]{12}[1-5][\da-f]{3}[89ab][\da-f]{15}$/i
- FORMAT =
'%032x'.freeze
Instance Method Summary collapse
Instance Method Details
#decode(value) ⇒ Object
11 12 13 14 15 |
# File 'lib/uuid4/formatter/compact.rb', line 11 def decode(value) if value.respond_to?(:to_str) && (value = value.to_str) =~ REGEXP value.hex end end |
#encode(uuid) ⇒ Object
7 8 9 |
# File 'lib/uuid4/formatter/compact.rb', line 7 def encode(uuid) FORMAT % uuid.to_int end |