Class: PictureTag::Parsers::TagParser
- Inherits:
-
Object
- Object
- PictureTag::Parsers::TagParser
- Defined in:
- lib/jekyll_picture_tag/parsers/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 keep. HTML attributes are handed off to its respective class (as 'leftovers')
Media presets and source names are stored as arrays in their correct orders. Crop settings 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
-
#crop ⇒ Object
readonly
Returns the value of attribute crop.
-
#keep ⇒ Object
readonly
Returns the value of attribute keep.
-
#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.
23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/jekyll_picture_tag/parsers/tag_parser.rb', line 23 def initialize(raw_params) @raw_params = raw_params @params = split_params @media_presets = [] @source_names = [] @keep = {} @crop = {} parse_params end |
Instance Attribute Details
#crop ⇒ Object (readonly)
Returns the value of attribute crop.
20 21 22 |
# File 'lib/jekyll_picture_tag/parsers/tag_parser.rb', line 20 def crop @crop end |
#keep ⇒ Object (readonly)
Returns the value of attribute keep.
20 21 22 |
# File 'lib/jekyll_picture_tag/parsers/tag_parser.rb', line 20 def keep @keep end |
#leftovers ⇒ Object (readonly)
Returns the value of attribute leftovers.
20 21 22 |
# File 'lib/jekyll_picture_tag/parsers/tag_parser.rb', line 20 def leftovers @leftovers end |
#media_presets ⇒ Object (readonly)
Returns the value of attribute media_presets.
20 21 22 |
# File 'lib/jekyll_picture_tag/parsers/tag_parser.rb', line 20 def media_presets @media_presets end |
#preset_name ⇒ Object (readonly)
Returns the value of attribute preset_name.
20 21 22 |
# File 'lib/jekyll_picture_tag/parsers/tag_parser.rb', line 20 def preset_name @preset_name end |
#source_names ⇒ Object (readonly)
Returns the value of attribute source_names.
20 21 22 |
# File 'lib/jekyll_picture_tag/parsers/tag_parser.rb', line 20 def source_names @source_names end |