Sha256: b84db4b6fade30794d1d78d17253b9d5bd694cd0672300a2b96544e78742375e
Contents?: true
Size: 768 Bytes
Versions: 3
Compression:
Stored size: 768 Bytes
Contents
# frozen_string_literal: true require_relative './character_set' module RakeSecrets module Types class Alphanumeric LOWERCASE_CHARACTERS = ('a'..'z').to_a UPPERCASE_CHARACTERS = ('A'..'Z').to_a NUMBER_CHARACTERS = ('0'..'9').to_a def initialize(opts = {}) @delegate = CharacterSet.new( character_set(opts[:case]), length: opts[:length] || 32 ) end def generate @delegate.generate end private def character_set(case_type) characters = NUMBER_CHARACTERS characters += UPPERCASE_CHARACTERS if %i[upper both].include?(case_type) characters += LOWERCASE_CHARACTERS unless case_type == :upper characters end end end end
Version data entries
3 entries across 3 versions & 1 rubygems