Class: JekyllLazyLoadImage::SiteConfig
- Inherits:
-
Object
- Object
- JekyllLazyLoadImage::SiteConfig
- Defined in:
- lib/jekyll-lazy-load-image/site-config.rb
Constant Summary collapse
- CONFIG_KEY =
"lazy_load_image"
Instance Method Summary collapse
- #additional_attrs ⇒ Object
- #class_attr_values ⇒ Object
- #ignore_selectors ⇒ Object
-
#initialize(lazy_load_image_config) ⇒ SiteConfig
constructor
A new instance of SiteConfig.
- #preload_image ⇒ Object
- #src_attr_name ⇒ Object
Constructor Details
#initialize(lazy_load_image_config) ⇒ SiteConfig
Returns a new instance of SiteConfig.
7 8 9 |
# File 'lib/jekyll-lazy-load-image/site-config.rb', line 7 def initialize(lazy_load_image_config) @lazy_load_image_config = lazy_load_image_config end |
Instance Method Details
#additional_attrs ⇒ Object
11 12 13 14 15 16 |
# File 'lib/jekyll-lazy-load-image/site-config.rb', line 11 def additional_attrs config_key = "additional_attrs" @additional_attrs ||= (@lazy_load_image_config&.[](config_key) || {}).tap do |attrs| raise "#{config_key} must be associative array. But passed #{attrs || "nil"}" unless attrs.is_a?(Hash) end end |
#class_attr_values ⇒ Object
18 19 20 21 22 23 |
# File 'lib/jekyll-lazy-load-image/site-config.rb', line 18 def class_attr_values config_key = "class_attr_values" @class_attr_values ||= Array( @lazy_load_image_config&.[](config_key) ).compact end |
#ignore_selectors ⇒ Object
25 26 27 28 29 30 |
# File 'lib/jekyll-lazy-load-image/site-config.rb', line 25 def ignore_selectors config_key = "ignore_selectors" @ignore_selectors ||= Array( @lazy_load_image_config&.[](config_key) ).map(&:to_s).reject(&:empty?) end |
#preload_image ⇒ Object
32 33 34 35 |
# File 'lib/jekyll-lazy-load-image/site-config.rb', line 32 def preload_image config_key = "preload_image" @preload_image ||= @lazy_load_image_config&.[](config_key).to_s.strip end |
#src_attr_name ⇒ Object
37 38 39 40 41 42 |
# File 'lib/jekyll-lazy-load-image/site-config.rb', line 37 def src_attr_name config_key = "src_attr_name" @src_attr_name ||= @lazy_load_image_config&.[](config_key).to_s.strip.tap do |name| raise "You must set #{config_key} config attribute of #{CONFIG_KEY}" if name.empty? end end |