Class: PictureTag::Instructions::Preset

Inherits:
Object
  • Object
show all
Defined in:
lib/jekyll_picture_tag/instructions/preset.rb

Overview

Handles the specific tag image set to construct.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ Preset

Returns a new instance of Preset.



6
7
8
9
# File 'lib/jekyll_picture_tag/instructions/preset.rb', line 6

def initialize(name)
  @name = name
  @content = build_preset
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



5
6
7
# File 'lib/jekyll_picture_tag/instructions/preset.rb', line 5

def name
  @name
end

Instance Method Details

#[](key) ⇒ Object



11
12
13
# File 'lib/jekyll_picture_tag/instructions/preset.rb', line 11

def [](key)
  @content[key]
end

#fallback_formatObject



26
27
28
# File 'lib/jekyll_picture_tag/instructions/preset.rb', line 26

def fallback_format
  @content['fallback_format']
end

#fallback_widthObject



30
31
32
# File 'lib/jekyll_picture_tag/instructions/preset.rb', line 30

def fallback_width
  @content['fallback_width']
end

#formatsObject



22
23
24
# File 'lib/jekyll_picture_tag/instructions/preset.rb', line 22

def formats
  @content['formats']
end

#nomarkdown?Boolean

Allows a per-preset hard override of the global nomarkdown setting and JPT’s feeble attempts at auto-detection.

Returns:

  • (Boolean)


36
37
38
39
40
41
42
# File 'lib/jekyll_picture_tag/instructions/preset.rb', line 36

def nomarkdown?
  if @content['nomarkdown'].nil?
    PictureTag.config.nomarkdown?
  else
    @content['nomarkdown']
  end
end

#quality(format = nil) ⇒ Object



44
45
46
47
48
49
# File 'lib/jekyll_picture_tag/instructions/preset.rb', line 44

def quality(format = nil)
  qualities = @content['format_quality'] || {}
  qualities.default = @content['quality']

  qualities[format]
end

#widths(media) ⇒ Object

Returns the set of widths to use for a given media query.



16
17
18
19
20
# File 'lib/jekyll_picture_tag/instructions/preset.rb', line 16

def widths(media)
  width_hash = self['media_widths'] || {}
  width_hash.default = self['widths']
  width_hash[media]
end