Class: EncodedId::Encoders::BaseConfiguration
- Inherits:
-
Object
- Object
- EncodedId::Encoders::BaseConfiguration
- Defined in:
- lib/encoded_id/encoders/base_configuration.rb
Overview
Base configuration class for encoder-specific settings This provides common parameters shared across all encoders
Direct Known Subclasses
Instance Attribute Summary collapse
-
#alphabet ⇒ Object
readonly
: Alphabet.
-
#blocklist ⇒ Object
readonly
: Blocklist.
-
#blocklist_max_length ⇒ Object
readonly
: Integer.
-
#blocklist_mode ⇒ Object
readonly
: Symbol.
-
#hex_digit_encoding_group_size ⇒ Object
readonly
: Integer.
-
#max_inputs_per_id ⇒ Object
readonly
: Integer.
-
#max_length ⇒ Object
readonly
: Integer?.
-
#min_length ⇒ Object
readonly
: Integer.
-
#split_at ⇒ Object
readonly
: Integer?.
-
#split_with ⇒ Object
readonly
: String?.
Instance Method Summary collapse
- #create_encoder ⇒ Object
-
#initialize(min_length: 8, alphabet: Alphabet.modified_crockford, split_at: 4, split_with: "-", hex_digit_encoding_group_size: 4, max_length: 128, max_inputs_per_id: 32, blocklist: Blocklist.empty, blocklist_mode: :length_threshold, blocklist_max_length: 32) ⇒ BaseConfiguration
constructor
A new instance of BaseConfiguration.
Constructor Details
#initialize(min_length: 8, alphabet: Alphabet.modified_crockford, split_at: 4, split_with: "-", hex_digit_encoding_group_size: 4, max_length: 128, max_inputs_per_id: 32, blocklist: Blocklist.empty, blocklist_mode: :length_threshold, blocklist_max_length: 32) ⇒ BaseConfiguration
Returns a new instance of BaseConfiguration.
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/encoded_id/encoders/base_configuration.rb', line 22 def initialize( min_length: 8, alphabet: Alphabet.modified_crockford, split_at: 4, split_with: "-", hex_digit_encoding_group_size: 4, max_length: 128, max_inputs_per_id: 32, blocklist: Blocklist.empty, blocklist_mode: :length_threshold, blocklist_max_length: 32 ) @min_length = validate_min_length(min_length) @alphabet = validate_alphabet(alphabet) @split_at = validate_split_at(split_at) @split_with = validate_split_with(split_with, @alphabet) @hex_digit_encoding_group_size = hex_digit_encoding_group_size @max_length = validate_max_length(max_length) @max_inputs_per_id = validate_max_inputs_per_id(max_inputs_per_id) @blocklist = validate_blocklist(blocklist) @blocklist = @blocklist.filter_for_alphabet(@alphabet) unless @blocklist.empty? @blocklist_mode = validate_blocklist_mode(blocklist_mode) @blocklist_max_length = validate_blocklist_max_length(blocklist_max_length) validate_blocklist_collision_risk end |
Instance Attribute Details
#alphabet ⇒ Object (readonly)
: Alphabet
11 12 13 |
# File 'lib/encoded_id/encoders/base_configuration.rb', line 11 def alphabet @alphabet end |
#blocklist ⇒ Object (readonly)
: Blocklist
17 18 19 |
# File 'lib/encoded_id/encoders/base_configuration.rb', line 17 def blocklist @blocklist end |
#blocklist_max_length ⇒ Object (readonly)
: Integer
19 20 21 |
# File 'lib/encoded_id/encoders/base_configuration.rb', line 19 def blocklist_max_length @blocklist_max_length end |
#blocklist_mode ⇒ Object (readonly)
: Symbol
18 19 20 |
# File 'lib/encoded_id/encoders/base_configuration.rb', line 18 def blocklist_mode @blocklist_mode end |
#hex_digit_encoding_group_size ⇒ Object (readonly)
: Integer
14 15 16 |
# File 'lib/encoded_id/encoders/base_configuration.rb', line 14 def hex_digit_encoding_group_size @hex_digit_encoding_group_size end |
#max_inputs_per_id ⇒ Object (readonly)
: Integer
16 17 18 |
# File 'lib/encoded_id/encoders/base_configuration.rb', line 16 def max_inputs_per_id @max_inputs_per_id end |
#max_length ⇒ Object (readonly)
: Integer?
15 16 17 |
# File 'lib/encoded_id/encoders/base_configuration.rb', line 15 def max_length @max_length end |
#min_length ⇒ Object (readonly)
: Integer
10 11 12 |
# File 'lib/encoded_id/encoders/base_configuration.rb', line 10 def min_length @min_length end |
#split_at ⇒ Object (readonly)
: Integer?
12 13 14 |
# File 'lib/encoded_id/encoders/base_configuration.rb', line 12 def split_at @split_at end |
#split_with ⇒ Object (readonly)
: String?
13 14 15 |
# File 'lib/encoded_id/encoders/base_configuration.rb', line 13 def split_with @split_with end |
Instance Method Details
#create_encoder ⇒ Object
49 50 51 |
# File 'lib/encoded_id/encoders/base_configuration.rb', line 49 def create_encoder raise NotImplementedError, "Subclasses must implement create_encoder" end |