Class: PictureTag::Instructions::TagParser
- Inherits:
-
Object
- Object
- PictureTag::Instructions::TagParser
- Defined in:
- lib/jekyll_picture_tag/instructions/tag_parser.rb
Overview
Tag Parsing Responsibilities:
{% picture mypreset a.jpg 3:2 mobile: b.jpg --alt "Alt" --link "/" %}
| Jekyll | TagParser | HTMLAttributes |
This class takes the arguments handed to the liquid tag (given as a simple string), hands them to ArgSplitter (which breaks them up into an array of words), extracts the preset name (if present), source image name(s), associated media queries (if present), and image-related arguments such as crop and gravity. HTML attributes are handed off to its respective class (as ‘leftovers’)
Media presets and source names are stored as arrays in their correct orders. Gravities and geometries are stored in a hash, keyed by their relevant media presets. Note that the base image will have a media preset of nil, which is a perfectly fine hash key.
Instance Attribute Summary collapse
-
#geometries ⇒ Object
readonly
Returns the value of attribute geometries.
-
#gravities ⇒ Object
readonly
Returns the value of attribute gravities.
-
#leftovers ⇒ Object
readonly
Returns the value of attribute leftovers.
-
#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.
Constructor Details
#initialize(raw_params) ⇒ TagParser
Returns a new instance of TagParser.
24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/jekyll_picture_tag/instructions/tag_parser.rb', line 24 def initialize(raw_params) @raw_params = raw_params @params = split_params @media_presets = [] @source_names = [] @geometries = {} @gravities = {} parse_params end |
Instance Attribute Details
#geometries ⇒ Object (readonly)
Returns the value of attribute geometries.
21 22 23 |
# File 'lib/jekyll_picture_tag/instructions/tag_parser.rb', line 21 def geometries @geometries end |
#gravities ⇒ Object (readonly)
Returns the value of attribute gravities.
21 22 23 |
# File 'lib/jekyll_picture_tag/instructions/tag_parser.rb', line 21 def gravities @gravities end |
#leftovers ⇒ Object (readonly)
Returns the value of attribute leftovers.
21 22 23 |
# File 'lib/jekyll_picture_tag/instructions/tag_parser.rb', line 21 def leftovers @leftovers end |
#media_presets ⇒ Object (readonly)
Returns the value of attribute media_presets.
21 22 23 |
# File 'lib/jekyll_picture_tag/instructions/tag_parser.rb', line 21 def media_presets @media_presets end |
#preset_name ⇒ Object (readonly)
Returns the value of attribute preset_name.
21 22 23 |
# File 'lib/jekyll_picture_tag/instructions/tag_parser.rb', line 21 def preset_name @preset_name end |
#source_names ⇒ Object (readonly)
Returns the value of attribute source_names.
21 22 23 |
# File 'lib/jekyll_picture_tag/instructions/tag_parser.rb', line 21 def source_names @source_names end |