Class: GeneratedImage
- Inherits:
-
Object
- Object
- GeneratedImage
- Defined in:
- lib/jekyll-4-picture-tag/generated_image.rb
Overview
Generated Image Represents a generated source file.
Instance Method Summary collapse
- #absolute_filename ⇒ Object
-
#initialize(source_file:, width:, format:) ⇒ GeneratedImage
constructor
A new instance of GeneratedImage.
- #name ⇒ Object
- #width ⇒ Object
Constructor Details
#initialize(source_file:, width:, format:) ⇒ GeneratedImage
Returns a new instance of GeneratedImage.
7 8 9 10 11 12 13 14 |
# File 'lib/jekyll-4-picture-tag/generated_image.rb', line 7 def initialize(source_file:, width:, format:) @source = source_file @format = format @size = build_size(width) generate_image unless File.exist? absolute_filename end |
Instance Method Details
#absolute_filename ⇒ Object
23 24 25 |
# File 'lib/jekyll-4-picture-tag/generated_image.rb', line 23 def absolute_filename @absolute_filename ||= File.join(PictureTag.config.dest_dir, name) end |
#name ⇒ Object
16 17 18 19 20 21 |
# File 'lib/jekyll-4-picture-tag/generated_image.rb', line 16 def name name = @source.base_name name << "-#{@size[:width]}by#{@size[:height]}-" name << @source.digest name << '.' + @format end |
#width ⇒ Object
27 28 29 |
# File 'lib/jekyll-4-picture-tag/generated_image.rb', line 27 def width @size[:width] end |