Class: DynamicLinks::ShorteningStrategies::NanoIDStrategy
- Inherits:
-
BaseStrategy
- Object
- BaseStrategy
- DynamicLinks::ShorteningStrategies::NanoIDStrategy
- 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
- #always_growing? ⇒ Boolean
-
#shorten(url, min_length: MIN_LENGTH) ⇒ Object
Shortens the given URL using Nano ID.
Instance Method Details
#always_growing? ⇒ Boolean
13 14 15 |
# File 'lib/dynamic_links/shortening_strategies/nano_id_strategy.rb', line 13 def always_growing? true # This strategy always generates a new shortened URL end |
#shorten(url, min_length: MIN_LENGTH) ⇒ Object
Shortens the given URL using Nano ID
9 10 11 |
# File 'lib/dynamic_links/shortening_strategies/nano_id_strategy.rb', line 9 def shorten(url, min_length: MIN_LENGTH) ::Nanoid.generate(size: min_length) end |