Class: PictureTag::Instructions::TagParser
- Inherits:
-
Object
- Object
- PictureTag::Instructions::TagParser
- Defined in:
- lib/jekyll-4-picture-tag/instructions/tag_parser.rb
Overview
This class takes the string given to the jekyll tag, and extracts useful information from it.
Instance Attribute Summary collapse
-
#html_attributes_raw ⇒ Object
readonly
Returns the value of attribute html_attributes_raw.
-
#preset_name ⇒ Object
readonly
Returns the value of attribute preset_name.
-
#source_images ⇒ Object
readonly
Returns the value of attribute source_images.
Instance Method Summary collapse
-
#initialize(raw_params) ⇒ TagParser
constructor
A new instance of TagParser.
Constructor Details
#initialize(raw_params) ⇒ TagParser
Returns a new instance of TagParser.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/jekyll-4-picture-tag/instructions/tag_parser.rb', line 7 def initialize(raw_params) @params = PictureTag::Utils.liquid_lookup(raw_params).split @preset_name = grab_preset_name # source_image keys are media queries, values are source images. The # first param specified will be our base image, so it has no associated # media query. Yes, nil can be a hash key. source_image_names = { nil => @params.shift } # Store source keys which fit a pattern in a hash. while @params.first =~ /[\w\-]+:/ media_query = @params.shift[0..-2] source_image_names[media_query] = @params.shift end @source_images = build_sources(source_image_names) # Anything left will be html attributes @html_attributes_raw = @params.join(' ') end |
Instance Attribute Details
#html_attributes_raw ⇒ Object (readonly)
Returns the value of attribute html_attributes_raw.
6 7 8 |
# File 'lib/jekyll-4-picture-tag/instructions/tag_parser.rb', line 6 def html_attributes_raw @html_attributes_raw end |
#preset_name ⇒ Object (readonly)
Returns the value of attribute preset_name.
6 7 8 |
# File 'lib/jekyll-4-picture-tag/instructions/tag_parser.rb', line 6 def preset_name @preset_name end |
#source_images ⇒ Object (readonly)
Returns the value of attribute source_images.
6 7 8 |
# File 'lib/jekyll-4-picture-tag/instructions/tag_parser.rb', line 6 def source_images @source_images end |