Class: PictureTag::Instructions::TagParser
- Inherits:
-
Object
- Object
- PictureTag::Instructions::TagParser
- Defined in:
- lib/jekyll_picture_tag/instructions/tag_parser.rb
Overview
This tag takes the arguments handed to the liquid tag, and extracts the preset name (if present), source image name(s), and associated media queries (if present). The leftovers (html attributes) are handed off to its respective class.
Instance Attribute Summary collapse
-
#media_presets ⇒ Object
readonly
Returns the value of attribute media_presets.
-
#preset_name ⇒ Object
readonly
Returns the value of attribute preset_name.
-
#source_names ⇒ Object
readonly
Returns the value of attribute source_names.
Instance Method Summary collapse
-
#initialize(raw_params) ⇒ TagParser
constructor
A new instance of TagParser.
- #leftovers ⇒ Object
Constructor Details
#initialize(raw_params) ⇒ TagParser
Returns a new instance of TagParser.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/jekyll_picture_tag/instructions/tag_parser.rb', line 9 def initialize(raw_params) build_params PictureTag::Utils.liquid_lookup(raw_params) @preset_name = grab_preset_name # The first param specified will be our base image, so it has no # associated media query. @media_presets = [] @source_names = [] << strip_quotes(@params.shift) # Detect and store arguments of the format 'media_query: img.jpg' as # keys and values. add_media_source while @params.first =~ /[\w\-]+:$/ end |
Instance Attribute Details
#media_presets ⇒ Object (readonly)
Returns the value of attribute media_presets.
8 9 10 |
# File 'lib/jekyll_picture_tag/instructions/tag_parser.rb', line 8 def media_presets @media_presets end |
#preset_name ⇒ Object (readonly)
Returns the value of attribute preset_name.
8 9 10 |
# File 'lib/jekyll_picture_tag/instructions/tag_parser.rb', line 8 def preset_name @preset_name end |
#source_names ⇒ Object (readonly)
Returns the value of attribute source_names.
8 9 10 |
# File 'lib/jekyll_picture_tag/instructions/tag_parser.rb', line 8 def source_names @source_names end |
Instance Method Details
#leftovers ⇒ Object
24 25 26 |
# File 'lib/jekyll_picture_tag/instructions/tag_parser.rb', line 24 def leftovers @params end |