Module: Imgproxy::OptionsCasters::Gravity
- Defined in:
- lib/imgproxy/options_casters/gravity.rb
Overview
Casts ‘gravity` processing option
Constant Summary collapse
- CLASS_NAMES_CASTER =
Imgproxy::OptionsCasters::Group.new( class_names: Imgproxy::OptionsCasters::Array, )
- OFFSETS_CASTER =
Imgproxy::OptionsCasters::Group.new( x_offset: Imgproxy::OptionsCasters::Float, y_offset: Imgproxy::OptionsCasters::Float, )
Class Method Summary collapse
Class Method Details
.cast(raw) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/imgproxy/options_casters/gravity.rb', line 23 def self.cast(raw) return raw unless raw.is_a?(Hash) return unless raw[:type] type = Imgproxy::OptionsCasters::String.cast(raw[:type]) case type when "sm" then type when "obj" then [type, *CLASS_NAMES_CASTER.cast(raw)].trim! else [type, *OFFSETS_CASTER.cast(raw)].trim! end end |