Sha256: 9c210f9085d14a6dd497680aa30a93306ce931dc3771fdf50c449b156ae679c8
Contents?: true
Size: 453 Bytes
Versions: 1
Compression:
Stored size: 453 Bytes
Contents
# frozen_string_literal: true class UUID4 module Formatter class Default 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' def encode(uuid) FORMAT % uuid.components end def decode(value) return unless value.respond_to?(:to_str) && (value = value.to_str) =~ REGEXP value.tr('-', '').hex end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
uuid4-1.4.0 | lib/uuid4/formatter/default.rb |