Module: Imgproxy::OptionsCasters::Background

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

Overview

Casts ‘background` info option

Constant Summary collapse

CASTER =
Imgproxy::OptionsCasters::Group.new(
  r: Imgproxy::OptionsCasters::Integer,
  g: Imgproxy::OptionsCasters::Integer,
  b: Imgproxy::OptionsCasters::Integer,
).freeze

Class Method Summary collapse

Class Method Details

.cast(raw) ⇒ Object



17
18
19
20
21
22
23
24
# File 'lib/imgproxy/options_casters/background.rb', line 17

def self.cast(raw)
  return raw.map { |v| Imgproxy::OptionsCasters::Integer.cast(v) } if raw.is_a?(::Array)

  return raw unless raw.is_a?(Hash)
  return Imgproxy::OptionsCasters::String.cast(raw[:hex_color]) if raw.key?(:hex_color)

  CASTER.cast(raw)
end