class JekyllLazyLoadImage::SiteConfig

Constants

CONFIG_KEY

Public Class Methods

new(lazy_load_image_config) click to toggle source
# 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

Public Instance Methods

additional_attrs() click to toggle source
# 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() click to toggle source
# 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() click to toggle source
# 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() click to toggle source
# 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() click to toggle source
# 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