Class: CheesyGallery::ImageThumb

Inherits:
BaseImageFile
  • Object
show all
Defined in:
lib/cheesy-gallery/image_thumb.rb

Overview

This StaticFile subclass represents thumbnail images for each image. On ‘write()` it renders a 150x150 center crop of the source

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from BaseImageFile

#path, #write

Constructor Details

#initialize(site, collection, file, postfix, height, width) ⇒ ImageThumb

Returns a new instance of ImageThumb.



10
11
12
13
14
15
# File 'lib/cheesy-gallery/image_thumb.rb', line 10

def initialize(site, collection, file, postfix, height, width)
  super(site, collection, file, file.name + postfix)

  @height = height
  @width = width
end

Instance Attribute Details

#heightObject (readonly)

Returns the value of attribute height.



8
9
10
# File 'lib/cheesy-gallery/image_thumb.rb', line 8

def height
  @height
end

#widthObject (readonly)

Returns the value of attribute width.



8
9
10
# File 'lib/cheesy-gallery/image_thumb.rb', line 8

def width
  @width
end

Instance Method Details

#process_and_write(img, path) ⇒ Object

instead of copying, renders the thumbnail



18
19
20
21
# File 'lib/cheesy-gallery/image_thumb.rb', line 18

def process_and_write(img, path)
  img.resize_to_fill!(height, width)
  img.write(path)
end