Sha256: a37fb51e686b74faff08f47e49e20d9091ac618b45333f8f7b53f228ec3d850a

Contents?: true

Size: 764 Bytes

Versions: 1

Compression:

Stored size: 764 Bytes

Contents

# frozen_string_literal: true
require 'securerandom'

module HumanizedId
  DEFAULT_GENERATION_LENGTH = 24
  SIMILAR_NUMBERS_LETTERS = %w(0 O 1 I L 5 S 8 B).freeze
  VOWELS = %w(A E I O U).freeze
  CHARSET = (('0'..'9').to_a + ('A'..'Z').to_a - SIMILAR_NUMBERS_LETTERS - VOWELS).freeze

  class << self
    def humanize(id:, min_length: nil, prefix: '')
      Humanizer.new(id: id, min_length: min_length, prefix: prefix).generate_humanized_id
    end

    def generate_random(prefix: '', length: DEFAULT_GENERATION_LENGTH)
      RandGenerator.new(prefix: prefix, length: length).generate_random_humanized_id
    end
  end
  Error = Class.new(StandardError)
end

require 'humanized_id/version'
require 'humanized_id/humanizer'
require 'humanized_id/rand_generator'

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
humanized_id-0.4.0 lib/humanized_id.rb