Class: PictureTag::GeneratedImage
- Inherits:
-
Object
- Object
- PictureTag::GeneratedImage
- Defined in:
- lib/jekyll_picture_tag/images/generated_image.rb
Overview
Represents a generated image, but not the file itself. Its purpose is to make its properties available for query, and hand them off to the ImageFile class for generation.
Instance Attribute Summary collapse
-
#width ⇒ Object
readonly
Returns the value of attribute width.
Instance Method Summary collapse
-
#absolute_filename ⇒ Object
/home/dave/my_blog/_site/generated/somefolder/myimage-100-123abc.jpg ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^.
- #exists? ⇒ Boolean
- #format ⇒ Object
- #generate ⇒ Object
-
#initialize(source_file:, width:, format:) ⇒ GeneratedImage
constructor
A new instance of GeneratedImage.
-
#name ⇒ Object
/home/dave/my_blog/_site/generated/somefolder/myimage-100-123abc.jpg ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^.
- #quality ⇒ Object
-
#source_height ⇒ Object
Post crop.
-
#source_width ⇒ Object
Post crop.
-
#uri ⇒ Object
https://example.com/assets/somefolder/myimage-100-123abc.jpg ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^.
Constructor Details
#initialize(source_file:, width:, format:) ⇒ GeneratedImage
Returns a new instance of GeneratedImage.
10 11 12 13 14 |
# File 'lib/jekyll_picture_tag/images/generated_image.rb', line 10 def initialize(source_file:, width:, format:) @source = source_file @width = width @raw_format = format end |
Instance Attribute Details
#width ⇒ Object (readonly)
Returns the value of attribute width.
8 9 10 |
# File 'lib/jekyll_picture_tag/images/generated_image.rb', line 8 def width @width end |
Instance Method Details
#absolute_filename ⇒ Object
/home/dave/my_blog/_site/generated/somefolder/myimage-100-123abc.jpg ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
30 31 32 |
# File 'lib/jekyll_picture_tag/images/generated_image.rb', line 30 def absolute_filename @absolute_filename ||= File.join(PictureTag.dest_dir, name) end |
#exists? ⇒ Boolean
20 21 22 |
# File 'lib/jekyll_picture_tag/images/generated_image.rb', line 20 def exists? File.exist?(absolute_filename) end |
#format ⇒ Object
16 17 18 |
# File 'lib/jekyll_picture_tag/images/generated_image.rb', line 16 def format @format ||= process_format(@raw_format) end |
#generate ⇒ Object
24 25 26 |
# File 'lib/jekyll_picture_tag/images/generated_image.rb', line 24 def generate generate_image unless @source.missing || exists? end |
#name ⇒ Object
/home/dave/my_blog/_site/generated/somefolder/myimage-100-123abc.jpg ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
36 37 38 |
# File 'lib/jekyll_picture_tag/images/generated_image.rb', line 36 def name @name ||= "#{@source.base_name}-#{@width}-#{id}.#{@format}" end |
#quality ⇒ Object
56 57 58 |
# File 'lib/jekyll_picture_tag/images/generated_image.rb', line 56 def quality PictureTag.quality(format, width) end |
#source_height ⇒ Object
Post crop
52 53 54 |
# File 'lib/jekyll_picture_tag/images/generated_image.rb', line 52 def source_height image.height end |
#source_width ⇒ Object
Post crop
47 48 49 |
# File 'lib/jekyll_picture_tag/images/generated_image.rb', line 47 def source_width image.width end |
#uri ⇒ Object
https://example.com/assets/somefolder/myimage-100-123abc.jpg ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
42 43 44 |
# File 'lib/jekyll_picture_tag/images/generated_image.rb', line 42 def uri ImgURI.new(name).to_s end |