Class: PictureTag::ImgURI
- Inherits:
-
Object
- Object
- PictureTag::ImgURI
- Defined in:
- lib/jekyll_picture_tag/img_uri.rb
Overview
Represents a link to an image. We use the File library rather than the URI library to build these because it doesn’t like relative URIs.
Just give it a filename, and pass source_image: true if it’s not a generated image. Call to_s on it to get the link.
Instance Attribute Summary collapse
-
#filename ⇒ Object
readonly
Returns the value of attribute filename.
-
#source_image ⇒ Object
readonly
Returns the value of attribute source_image.
Instance Method Summary collapse
-
#initialize(filename, source_image: false) ⇒ ImgURI
constructor
A new instance of ImgURI.
-
#to_s ⇒ Object
| domain | baseurl | directory | filename.
Constructor Details
#initialize(filename, source_image: false) ⇒ ImgURI
Returns a new instance of ImgURI.
11 12 13 14 |
# File 'lib/jekyll_picture_tag/img_uri.rb', line 11 def initialize(filename, source_image: false) @source_image = source_image @filename = filename end |
Instance Attribute Details
#filename ⇒ Object (readonly)
Returns the value of attribute filename.
10 11 12 |
# File 'lib/jekyll_picture_tag/img_uri.rb', line 10 def filename @filename end |
#source_image ⇒ Object (readonly)
Returns the value of attribute source_image.
10 11 12 |
# File 'lib/jekyll_picture_tag/img_uri.rb', line 10 def source_image @source_image end |
Instance Method Details
#to_s ⇒ Object
| domain | baseurl | directory | filename
18 19 20 21 22 |
# File 'lib/jekyll_picture_tag/img_uri.rb', line 18 def to_s Addressable::URI.escape( File.join(domain, baseurl, directory, @filename) ) end |