Module: StoryKey::ClassMethods
- Included in:
- StoryKey
- Defined in:
- lib/story_key/class_methods.rb
Instance Method Summary collapse
- #decode ⇒ Object
- #encode ⇒ Object
- #generate(bitsize: StoryKey::DEFAULT_BITSIZE) ⇒ Object
- #recover ⇒ Object
Instance Method Details
#decode ⇒ Object
7 8 9 |
# File 'lib/story_key/class_methods.rb', line 7 def decode(...) StoryKey::Decoder.call(...) end |
#encode ⇒ Object
3 4 5 |
# File 'lib/story_key/class_methods.rb', line 3 def encode(...) StoryKey::Encoder.call(...) end |
#generate(bitsize: StoryKey::DEFAULT_BITSIZE) ⇒ Object
15 16 17 18 19 20 |
# File 'lib/story_key/class_methods.rb', line 15 def generate(bitsize: StoryKey::DEFAULT_BITSIZE) key = StoryKey::Generator.call(bitsize:) encoded = encode(key:, bitsize:) raise 'An error occurred!' if key != decode(story: encoded.text) [key, encoded] end |