Class: JekyllAutoThumbnails::Configuration
- Inherits:
-
Object
- Object
- JekyllAutoThumbnails::Configuration
- Defined in:
- lib/jekyll-auto-thumbnails/configuration.rb
Overview
Configuration parser for auto_thumbnails settings
Parses Jekyll site config for auto_thumbnails options and provides accessor methods with appropriate defaults and validation.
Constant Summary collapse
- VALID_PARSERS =
%i[html4 html5].freeze
Instance Attribute Summary collapse
-
#cache_dir ⇒ Object
readonly
Returns the value of attribute cache_dir.
-
#max_height ⇒ Object
readonly
Returns the value of attribute max_height.
-
#max_width ⇒ Object
readonly
Returns the value of attribute max_width.
-
#parser ⇒ Object
readonly
Returns the value of attribute parser.
-
#quality ⇒ Object
readonly
Returns the value of attribute quality.
Instance Method Summary collapse
-
#enabled? ⇒ Boolean
Check if image optimization is enabled.
-
#initialize(site) ⇒ Configuration
constructor
Initialize configuration from Jekyll site.
Constructor Details
#initialize(site) ⇒ Configuration
Initialize configuration from Jekyll site
16 17 18 19 20 21 22 23 24 25 |
# File 'lib/jekyll-auto-thumbnails/configuration.rb', line 16 def initialize(site) config_hash = site.config["auto_thumbnails"] || {} @enabled = config_hash.fetch("enabled", true) @max_width = parse_dimension(config_hash["max_width"]) @max_height = parse_dimension(config_hash["max_height"]) @quality = parse_quality(config_hash.fetch("quality", 85)) @parser = parse_parser(config_hash.fetch("parser", "html5")) @cache_dir = File.join(site.source, ".jekyll-cache", "jekyll-auto-thumbnails") end |
Instance Attribute Details
#cache_dir ⇒ Object (readonly)
Returns the value of attribute cache_dir.
11 12 13 |
# File 'lib/jekyll-auto-thumbnails/configuration.rb', line 11 def cache_dir @cache_dir end |
#max_height ⇒ Object (readonly)
Returns the value of attribute max_height.
11 12 13 |
# File 'lib/jekyll-auto-thumbnails/configuration.rb', line 11 def max_height @max_height end |
#max_width ⇒ Object (readonly)
Returns the value of attribute max_width.
11 12 13 |
# File 'lib/jekyll-auto-thumbnails/configuration.rb', line 11 def max_width @max_width end |
#parser ⇒ Object (readonly)
Returns the value of attribute parser.
11 12 13 |
# File 'lib/jekyll-auto-thumbnails/configuration.rb', line 11 def parser @parser end |
#quality ⇒ Object (readonly)
Returns the value of attribute quality.
11 12 13 |
# File 'lib/jekyll-auto-thumbnails/configuration.rb', line 11 def quality @quality end |
Instance Method Details
#enabled? ⇒ Boolean
Check if image optimization is enabled
30 31 32 |
# File 'lib/jekyll-auto-thumbnails/configuration.rb', line 30 def enabled? @enabled end |