Class: StoryKey::Encoder

Inherits:
Base
  • Object
show all
Defined in:
lib/story_key/encoder.rb

Constant Summary collapse

BASE58_REGEX =
/\A[1-9A-Za-z]+\Z/
DEC_REGEX =
/\A\d+\Z/
HEX_REGEX =
/\A[\da-f]+\Z/
BIN_REGEX =
/\A[0-1]+\Z/
COLORS =
{
  adjective: 36,
  noun: 33,
  preposition: nil,
  slug: 31,
  verb: 35
}.freeze

Instance Method Summary collapse

Methods inherited from Base

call

Instance Method Details

#callObject



19
20
21
22
23
24
25
26
27
# File 'lib/story_key/encoder.rb', line 19

def call
  @key = key.strip
  @format ||= StoryKey::FORMATS.first

  validate_format!
  validate_length!

  StoryKey::Story.new(text:, humanized:, tokenized:)
end