Class: JekyllAutoThumbnails::Registry
- Inherits:
-
Object
- Object
- JekyllAutoThumbnails::Registry
- Defined in:
- lib/jekyll-auto-thumbnails/registry.rb
Overview
Image requirement registry
Tracks images needing thumbnails and their required dimensions. Handles duplicate registrations by keeping the largest dimensions.
Instance Method Summary collapse
-
#entries ⇒ Hash
Get all registered entries.
-
#initialize ⇒ Registry
constructor
Initialize empty registry.
-
#register(url, width, height) ⇒ Object
Register an image with required dimensions.
-
#registered?(url) ⇒ Boolean
Check if image is registered.
-
#requirements_for(url) ⇒ Hash?
Get requirements for image.
Constructor Details
#initialize ⇒ Registry
Initialize empty registry
10 11 12 |
# File 'lib/jekyll-auto-thumbnails/registry.rb', line 10 def initialize @entries = {} end |
Instance Method Details
#entries ⇒ Hash
Get all registered entries
46 47 48 |
# File 'lib/jekyll-auto-thumbnails/registry.rb', line 46 def entries @entries.dup end |
#register(url, width, height) ⇒ Object
Register an image with required dimensions
19 20 21 22 23 24 25 |
# File 'lib/jekyll-auto-thumbnails/registry.rb', line 19 def register(url, width, height) previous = @entries[url] @entries[url] = { width: [previous&.dig(:width), width].compact.max, height: [previous&.dig(:height), height].compact.max } end |
#registered?(url) ⇒ Boolean
Check if image is registered
31 32 33 |
# File 'lib/jekyll-auto-thumbnails/registry.rb', line 31 def registered?(url) @entries.key?(url) end |
#requirements_for(url) ⇒ Hash?
Get requirements for image
39 40 41 |
# File 'lib/jekyll-auto-thumbnails/registry.rb', line 39 def requirements_for(url) @entries[url].dup end |