Class: DynamicLinks::ShorteningStrategies::NanoIDStrategy

Inherits:
BaseStrategy
  • Object
show all
Defined in:
lib/dynamic_links/shortening_strategies/nano_id_strategy.rb

Overview

Shortens the given URL using Nano ID This strategy will generate a different short URL for the same given URL

Constant Summary

Constants inherited from BaseStrategy

BaseStrategy::BASE62_CHARS, BaseStrategy::MIN_LENGTH

Instance Method Summary collapse

Instance Method Details

#shorten(url, size: MIN_LENGTH) ⇒ Object

Shortens the given URL using Nano ID

Parameters:

  • url (String)

    The URL to shorten (not directly used in Nano ID strategy)

  • size (Integer) (defaults to: MIN_LENGTH)

    The size (length) of the generated Nano ID



15
16
17
# File 'lib/dynamic_links/shortening_strategies/nano_id_strategy.rb', line 15

def shorten(url, size: MIN_LENGTH)
  ::Nanoid.generate(size: size)
end