Class: PictureTag::Instructions::Set
- Inherits:
-
Object
- Object
- PictureTag::Instructions::Set
- Defined in:
- lib/jekyll_picture_tag/instructions/set.rb
Overview
Supervisor class, which manages all input handling and high level decision making which depends on it.
Instance Method Summary collapse
- #config ⇒ Object
- #crop(media = nil) ⇒ Object
- #gravity(media = nil) ⇒ Object
- #html_attributes ⇒ Object
-
#initialize(raw_tag_params) ⇒ Set
constructor
A new instance of Set.
-
#media_presets ⇒ Object
These are our Media Query presets.
-
#output_class ⇒ Object
Returns a class constant for the selected output format, which is used to dynamically instantiate it.
- #params ⇒ Object
- #preset ⇒ Object
- #source_images ⇒ Object
Constructor Details
#initialize(raw_tag_params) ⇒ Set
Returns a new instance of Set.
6 7 8 |
# File 'lib/jekyll_picture_tag/instructions/set.rb', line 6 def initialize(raw_tag_params) @raw_tag_params = raw_tag_params end |
Instance Method Details
#config ⇒ Object
10 11 12 |
# File 'lib/jekyll_picture_tag/instructions/set.rb', line 10 def config @config ||= Configuration.new end |
#crop(media = nil) ⇒ Object
37 38 39 |
# File 'lib/jekyll_picture_tag/instructions/set.rb', line 37 def crop(media = nil) params.geometries[media] || preset.crop(media) end |
#gravity(media = nil) ⇒ Object
41 42 43 |
# File 'lib/jekyll_picture_tag/instructions/set.rb', line 41 def gravity(media = nil) params.gravities[media] || preset.gravity(media) end |
#html_attributes ⇒ Object
22 23 24 25 |
# File 'lib/jekyll_picture_tag/instructions/set.rb', line 22 def html_attributes # Depends on both the preset and tag params. @html_attributes ||= HTMLAttributeSet.new params.leftovers end |
#media_presets ⇒ Object
These are our Media Query presets. It’s really just a hash, and there are no default values, so extracting this to its own class is overkill.
29 30 31 |
# File 'lib/jekyll_picture_tag/instructions/set.rb', line 29 def media_presets search_data('media_queries') || search_data('media_presets') || {} end |
#output_class ⇒ Object
Returns a class constant for the selected output format, which is used to dynamically instantiate it.
47 48 49 50 51 |
# File 'lib/jekyll_picture_tag/instructions/set.rb', line 47 def output_class Object.const_get( 'PictureTag::OutputFormats::' + Utils.titleize(preset['markup']) ) end |
#params ⇒ Object
14 15 16 |
# File 'lib/jekyll_picture_tag/instructions/set.rb', line 14 def params @params ||= TagParser.new @raw_tag_params end |
#preset ⇒ Object
18 19 20 |
# File 'lib/jekyll_picture_tag/instructions/set.rb', line 18 def preset @preset ||= Preset.new params.preset_name end |
#source_images ⇒ Object
33 34 35 |
# File 'lib/jekyll_picture_tag/instructions/set.rb', line 33 def source_images @source_images ||= build_source_images end |