Sha256: 36347d9a3cfced8ca55c47ac20bab1c9c2c00c09990c2ed493cb108f5fba5313

Contents?: true

Size: 343 Bytes

Versions: 2

Compression:

Stored size: 343 Bytes

Contents

require 'base62-rb'

class UUID4
  module Formatter
    class Base62
      REGEXP = /^[0-9A-z]{22}$/i

      def encode(uuid)
        ::Base62.encode(uuid.to_i)
      end

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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
uuid4-1.1.0 lib/uuid4/formatter/base62.rb
uuid4-1.0.0 lib/uuid4/formatter/base62.rb