Class: Utopia::Tags::Gallery::Processes::Thumbnail
- Inherits:
-
Object
- Object
- Utopia::Tags::Gallery::Processes::Thumbnail
show all
- Defined in:
- lib/utopia/tags/gallery.rb
Instance Method Summary
collapse
Constructor Details
#initialize(size = [800, 800]) ⇒ Thumbnail
Returns a new instance of Thumbnail.
29
30
31
|
# File 'lib/utopia/tags/gallery.rb', line 29
def initialize(size = [800, 800])
@size = size
end
|
Instance Method Details
#call(img) ⇒ Object
33
34
35
36
37
38
39
40
|
# File 'lib/utopia/tags/gallery.rb', line 33
def call(img)
if (img.columns > @size[0] || img.rows > @size[1])
img.resize_to_fit(*@size)
else
img
end
end
|
#default_extension(path) ⇒ Object
42
43
44
45
46
47
48
49
50
51
|
# File 'lib/utopia/tags/gallery.rb', line 42
def default_extension(path)
ext = path.original.extension
case ext
when /pdf/i
return "png"
else
return ext.downcase
end
end
|