Class: UUID4::Formatter::Default
- Inherits:
-
Object
- Object
- UUID4::Formatter::Default
- Defined in:
- lib/uuid4/formatter/default.rb
Constant Summary collapse
- REGEXP =
/^[\da-f]{8}-[\da-f]{4}-[1-8][\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}$/i.freeze
- FORMAT =
'%08x-%04x-%04x-%04x-%012x'
Instance Method Summary collapse
Instance Method Details
#decode(value) ⇒ Object
13 14 15 16 17 |
# File 'lib/uuid4/formatter/default.rb', line 13 def decode(value) return unless value.respond_to?(:to_str) && (value = value.to_str) =~ REGEXP value.tr('-', '').hex end |
#encode(uuid) ⇒ Object
9 10 11 |
# File 'lib/uuid4/formatter/default.rb', line 9 def encode(uuid) FORMAT % uuid.components end |