module Imgproxy::OptionsCasters::Crop

Casts crop option

Public Class Methods

cast(raw) click to toggle source
# File lib/imgproxy/options_casters/crop.rb, line 11
def self.cast(raw)
  return raw unless raw.is_a?(Hash)
  return unless raw[:width] || raw[:height]

  [
    Imgproxy::OptionsCasters::Float.cast(raw[:width]) || 0,
    Imgproxy::OptionsCasters::Float.cast(raw[:height]) || 0,
    Imgproxy::OptionsCasters::Gravity.cast(raw[:gravity]),
  ].trim!
end