0
@@ -29,13 +29,16 @@ module Fleximage
0
def execute(*args) #:nodoc:
0
+ # Get the result of the Operators #operate method
0
result = operate(*args)
0
+ # Ensure that the result is an RMagick:Image object
0
unless result.is_a?(Magick::Image)
0
raise BadOperatorResult, "expected #{self.class}#operate to return an instance of Magick::Image. \n"+
0
"Got instance of #{result.class} instead."
0
+ # Save the result to the operator proxy
0
@@ -60,38 +63,42 @@ module Fleximage
0
# x, y = size_to_xy("10x20")
0
- if size.is_a?(Array) && size.size == 2
0
+ when size.is_a?(Array) && size.size == 2 # [320, 240]
0
- elsif size.to_s.include?('x')
0
+ when size.to_s.include?('x') # "320x240"
0
size.split('x').collect(&:to_i)
0
+ else # Anything else, convert the object to an integer and assume square dimensions
0
# Scale the image, respecting aspect ratio.
0
# Operation will happen in the main <tt>@image</tt> unless you supply the +img+ argument
0
# to operate on instead.
0
- def scale(size, img = nil)
0
- (img || @image).change_geometry!(size_to_xy(size).join('x')) do |cols, rows, img|
0
+ def scale(size, img = @image)
0
+ img.change_geometry!(size_to_xy(size).join('x')) do |cols, rows, _img|
0
-
img.resize!(cols, rows)
0
+
_img.resize!(cols, rows)
0
# Scale to the desired size and crop edges off to get the exact dimensions needed.
0
# Operation will happen in the main <tt>@image</tt> unless you supply the +img+ argument
0
# to operate on instead.
0
- def scale_and_crop(size, img = nil)
0
- (img || @image).crop_resized!(*size_to_xy(size))
0
+ def scale_and_crop(size, img = @image)
0
+ img.crop_resized!(*size_to_xy(size))
0
# Resize the image, with no respect to aspect ratio.
0
# Operation will happen in the main <tt>@image</tt> unless you supply the +img+ argument
0
# to operate on instead.
0
- def stretch(size, img = nil)
0
- (img || @image).resize!(*size_to_xy(size))
0
+ def stretch(size, img = @image)
0
+ img.resize!(*size_to_xy(size))
0
# Convert a symbol to an RMagick blending mode.