Module: Imgproxy::OptionsCasters::Average
- Defined in:
- lib/imgproxy/options_casters/average.rb
Overview
Casts ‘average` info option
Constant Summary collapse
- CASTER =
Imgproxy::OptionsCasters::Group.new( average: Imgproxy::OptionsCasters::Bool, ignore_transparent: Imgproxy::OptionsCasters::Bool, ).freeze
Class Method Summary collapse
Class Method Details
.cast(raw) ⇒ Object
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/imgproxy/options_casters/average.rb', line 15 def self.cast(raw) # Allow average to be just a boolean return Imgproxy::OptionsCasters::Bool.cast(raw) if [true, false].include?(raw) return raw unless raw.is_a?(Hash) return if raw[:average].nil? values = CASTER.cast(raw) values[0].zero? ? 0 : values end |