Class: PictureTag::Instructions::Preset
- Inherits:
-
Object
- Object
- PictureTag::Instructions::Preset
- Defined in:
- lib/jekyll-4-picture-tag/instructions/preset.rb
Overview
Handles the specific tag image set to construct.
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #[](key) ⇒ Object
- #fallback_format ⇒ Object
- #fallback_width ⇒ Object
-
#initialize ⇒ Preset
constructor
A new instance of Preset.
-
#widths(media) ⇒ Object
Returns the set of widths to use for a given media query.
Constructor Details
#initialize ⇒ Preset
Returns a new instance of Preset.
6 7 8 9 |
# File 'lib/jekyll-4-picture-tag/instructions/preset.rb', line 6 def initialize @name = PictureTag.preset_name @content = build_preset end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
5 6 7 |
# File 'lib/jekyll-4-picture-tag/instructions/preset.rb', line 5 def name @name end |
Instance Method Details
#[](key) ⇒ Object
11 12 13 |
# File 'lib/jekyll-4-picture-tag/instructions/preset.rb', line 11 def [](key) @content[key] end |
#fallback_format ⇒ Object
22 23 24 |
# File 'lib/jekyll-4-picture-tag/instructions/preset.rb', line 22 def fallback_format PictureTag::Utils.process_format(@content['fallback_format'], nil) end |
#fallback_width ⇒ Object
26 27 28 |
# File 'lib/jekyll-4-picture-tag/instructions/preset.rb', line 26 def fallback_width @content['fallback_width'] end |
#widths(media) ⇒ Object
Returns the set of widths to use for a given media query.
16 17 18 19 20 |
# File 'lib/jekyll-4-picture-tag/instructions/preset.rb', line 16 def widths(media) width_hash = self['media_widths'] || {} width_hash.default = self['widths'] width_hash[media] end |