Sha256: b58636373f2a9a18a8ac85d490428fc600821ca2b9cf526a87a08a6b597d637b
Contents?: true
Size: 1.05 KB
Versions: 4
Compression:
Stored size: 1.05 KB
Contents
# frozen_string_literal: true require 'uploadcare/errors/type_error' module Uploadcare module Rails module Transformations # A class for building image urls after image transformations. class ImageTransformations def initialize(options = {}) raise ArgumentError, "Options argument must be a Hash, #{options.class} is given?" unless options.is_a?(Hash) @options = options.map { |k, v| [k.to_sym, v] }.to_h end def call options_to_a.compact.join('-').squeeze('/').gsub(/\s/, '').presence end private attr_reader :options def options_to_a options.map do |key, value| "/#{key}/#{adjusted_value(value)}/" end end def adjusted_value(value) case value when Hash value.values.join('/') when TrueClass, FalseClass, 'true', 'false' nil when Array value.join(',') else value end end end end end end
Version data entries
4 entries across 4 versions & 1 rubygems