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
52 53 54 |
# File 'lib/jekyll-auto-thumbnails/registry.rb', line 52 def entries @entries.dup end |
#register(url, width, height) ⇒ Object
Register an image with required dimensions
19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/jekyll-auto-thumbnails/registry.rb', line 19 def register(url, width, height) existing = @entries[url] @entries[url] = if existing # Update to max dimensions { width: [existing[:width], width].compact.max, height: [existing[:height], height].compact.max } else { width: width, height: height } end end |
#registered?(url) ⇒ Boolean
Check if image is registered
37 38 39 |
# File 'lib/jekyll-auto-thumbnails/registry.rb', line 37 def registered?(url) @entries.key?(url) end |
#requirements_for(url) ⇒ Hash?
Get requirements for image
45 46 47 |
# File 'lib/jekyll-auto-thumbnails/registry.rb', line 45 def requirements_for(url) @entries[url]&.dup end |