Sha256: 920ca73bf47eaabda31a0ae0ec9ebe4eb0a3073969ce3f2da07069d4c7c35411

Contents?: true

Size: 365 Bytes

Versions: 10

Compression:

Stored size: 365 Bytes

Contents

class UUID4
  module Formatter
    class Compact
      REGEXP = /^[\da-f]{12}[1-5][\da-f]{3}[89ab][\da-f]{15}$/i
      FORMAT = '%032x'.freeze

      def encode(uuid)
        FORMAT % uuid.to_int
      end

      def decode(value)
        if value.respond_to?(:to_str) && (value = value.to_str) =~ REGEXP
          value.hex
        end
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
uuid4-1.3.4 lib/uuid4/formatter/compact.rb
uuid4-1.3.3 lib/uuid4/formatter/compact.rb
uuid4-1.3.2 lib/uuid4/formatter/compact.rb
uuid4-1.3.1 lib/uuid4/formatter/compact.rb
uuid4-1.3.0 lib/uuid4/formatter/compact.rb
uuid4-1.2.1 lib/uuid4/formatter/compact.rb
uuid4-1.2.0 lib/uuid4/formatter/compact.rb
uuid4-1.1.1 lib/uuid4/formatter/compact.rb
uuid4-1.1.0 lib/uuid4/formatter/compact.rb
uuid4-1.0.0 lib/uuid4/formatter/compact.rb