Class: PictureTag::Instructions::Preset

Inherits:
Object
  • Object
show all
Defined in:
lib/jekyll-4-picture-tag/instructions/preset.rb

Overview

Handles the specific tag image set to construct.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializePreset

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

#nameObject (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_formatObject



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_widthObject



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