Class: PictureTag::GeneratedImage
- Inherits:
-
Object
- Object
- PictureTag::GeneratedImage
- Includes:
- MiniMagick
- Defined in:
- lib/jekyll_picture_tag/images/generated_image.rb
Overview
Represents a generated image file.
Instance Attribute Summary collapse
-
#format ⇒ Object
readonly
Returns the value of attribute format.
-
#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
- #generate ⇒ Object
-
#initialize(source_file:, width:, format:, crop: nil, gravity: '') ⇒ GeneratedImage
constructor
A new instance of GeneratedImage.
-
#name ⇒ Object
/home/dave/my_blog/_site/generated/somefolder/myimage-100-123abc.jpg ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^.
-
#source_height ⇒ Object
Post crop.
-
#source_width ⇒ Object
Post crop.
-
#uri ⇒ Object
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^.
Constructor Details
#initialize(source_file:, width:, format:, crop: nil, gravity: '') ⇒ GeneratedImage
Returns a new instance of GeneratedImage.
10 11 12 13 14 15 16 |
# File 'lib/jekyll_picture_tag/images/generated_image.rb', line 10 def initialize(source_file:, width:, format:, crop: nil, gravity: '') @source = source_file @width = width @format = process_format format @crop = crop @gravity = gravity end |
Instance Attribute Details
#format ⇒ Object (readonly)
Returns the value of attribute format.
6 7 8 |
# File 'lib/jekyll_picture_tag/images/generated_image.rb', line 6 def format @format end |
#width ⇒ Object (readonly)
Returns the value of attribute width.
6 7 8 |
# File 'lib/jekyll_picture_tag/images/generated_image.rb', line 6 def width @width end |
Instance Method Details
#absolute_filename ⇒ Object
/home/dave/my_blog/_site/generated/somefolder/myimage-100-123abc.jpg ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
28 29 30 |
# File 'lib/jekyll_picture_tag/images/generated_image.rb', line 28 def absolute_filename @absolute_filename ||= File.join(PictureTag.dest_dir, name) end |
#exists? ⇒ Boolean
18 19 20 |
# File 'lib/jekyll_picture_tag/images/generated_image.rb', line 18 def exists? File.exist?(absolute_filename) end |
#generate ⇒ Object
22 23 24 |
# File 'lib/jekyll_picture_tag/images/generated_image.rb', line 22 def generate generate_image unless @source.missing || exists? end |
#name ⇒ Object
/home/dave/my_blog/_site/generated/somefolder/myimage-100-123abc.jpg
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
34 35 36 |
# File 'lib/jekyll_picture_tag/images/generated_image.rb', line 34 def name @name ||= "#{@source.base_name}-#{@width}-#{id}.#{@format}" end |
#source_height ⇒ Object
Post crop
52 53 54 55 56 |
# File 'lib/jekyll_picture_tag/images/generated_image.rb', line 52 def source_height update_cache unless cache[:height] cache[:height] end |
#source_width ⇒ Object
Post crop
45 46 47 48 49 |
# File 'lib/jekyll_picture_tag/images/generated_image.rb', line 45 def source_width update_cache unless cache[:width] cache[:width] end |