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.



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

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



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

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

#crop(media = nil) ⇒ Object

Crop value



54
55
56
# File 'lib/jekyll_picture_tag/instructions/preset.rb', line 54

def crop(media = nil)
  setting_lookup('crop', 'media', media)
end

#fallback_formatObject



20
21
22
# File 'lib/jekyll_picture_tag/instructions/preset.rb', line 20

def fallback_format
  @content['fallback_format']
end

#fallback_widthObject



24
25
26
# File 'lib/jekyll_picture_tag/instructions/preset.rb', line 24

def fallback_width
  @content['fallback_width']
end

#formatsObject



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

def formats
  @content['formats']
end

#gravity(media = nil) ⇒ Object

Gravity setting (for imagemagick cropping)



49
50
51
# File 'lib/jekyll_picture_tag/instructions/preset.rb', line 49

def gravity(media = nil)
  setting_lookup('gravity', 'media', media)
end

#nomarkdown?Boolean

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

Returns:

  • (Boolean)


30
31
32
33
34
35
36
# File 'lib/jekyll_picture_tag/instructions/preset.rb', line 30

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

#quality(format = nil) ⇒ Object

Image quality setting, possibly dependent on format.



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

def quality(format = nil)
  setting_lookup('quality', 'format', format)
end

#widths(media = nil) ⇒ Object

Image widths to generate for a given media query.



39
40
41
# File 'lib/jekyll_picture_tag/instructions/preset.rb', line 39

def widths(media = nil)
  setting_lookup('widths', 'media', media)
end