Module: Imgproxy::OptionsCasters::Trim

Defined in:
lib/imgproxy/options_casters/trim.rb

Overview

Casts ‘trim` processing option

Constant Summary collapse

CASTER =
Imgproxy::OptionsCasters::Group.new(
  threshold: Imgproxy::OptionsCasters::Float,
  color: Imgproxy::OptionsCasters::String,
  equal_hor: Imgproxy::OptionsCasters::Bool,
  equal_ver: Imgproxy::OptionsCasters::Bool,
).freeze

Class Method Summary collapse

Class Method Details

.cast(raw) ⇒ Object



19
20
21
22
23
24
25
26
27
# File 'lib/imgproxy/options_casters/trim.rb', line 19

def self.cast(raw)
  # Allow trim to be just a numeric
  return Imgproxy::OptionsCasters::Float.cast(raw) if raw.is_a?(Numeric)

  return raw unless raw.is_a?(Hash)
  return unless raw[:threshold]

  CASTER.cast(raw)
end