Sha256: 5954fb2218a726b78b288cf5475a5483e93811cc31e904555e66c57b61dc64a9

Contents?: true

Size: 1.61 KB

Versions: 19

Compression:

Stored size: 1.61 KB

Contents

# frozen_string_literal: true

module Uploadcare
  module Param
    module Conversion
      module Video
        class ProcessingJobUrlBuilder
          class << self
            # rubocop:disable Metrics/ParameterLists
            def call(uuid:, size: {}, quality: nil, format: nil, cut: {}, thumbs: {})
              [
                uuid_part(uuid),
                size_part(size),
                quality_part(quality),
                format_part(format),
                cut_part(cut),
                thumbs_part(thumbs)
              ].compact.join('-')
            end
            # rubocop:enable Metrics/ParameterLists

            private

            def uuid_part(uuid)
              "#{uuid}/video/"
            end

            def size_part(size)
              return if size.empty?

              dimensions = "#{size[:width]}x#{size[:height]}" if size[:width] || size[:height]
              resize_mode = (size[:resize_mode]).to_s
              "/size/#{dimensions}/#{resize_mode}/".squeeze('/')
            end

            def quality_part(quality)
              return if quality.nil?

              "/quality/#{quality}/"
            end

            def format_part(format)
              return if format.nil?

              "/format/#{format}/"
            end

            def cut_part(cut)
              return if cut.empty?

              "/cut/#{cut[:start_time]}/#{cut[:length]}/"
            end

            def thumbs_part(thumbs)
              return if thumbs.empty?

              "/thumbs~#{thumbs[:N]}/#{thumbs[:number]}/".squeeze('/')
            end
          end
        end
      end
    end
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
uploadcare-ruby-4.4.3 lib/uploadcare/param/conversion/video/processing_job_url_builder.rb
uploadcare-ruby-4.4.2 lib/uploadcare/param/conversion/video/processing_job_url_builder.rb
uploadcare-ruby-4.4.1 lib/uploadcare/param/conversion/video/processing_job_url_builder.rb
uploadcare-ruby-4.4.0 lib/uploadcare/param/conversion/video/processing_job_url_builder.rb
uploadcare-ruby-4.3.6 lib/uploadcare/param/conversion/video/processing_job_url_builder.rb
uploadcare-ruby-4.3.5 lib/uploadcare/param/conversion/video/processing_job_url_builder.rb
uploadcare-ruby-4.3.4 lib/uploadcare/param/conversion/video/processing_job_url_builder.rb
uploadcare-ruby-4.3.3 lib/uploadcare/param/conversion/video/processing_job_url_builder.rb
uploadcare-ruby-4.3.2 lib/uploadcare/param/conversion/video/processing_job_url_builder.rb
uploadcare-ruby-4.3.1 lib/uploadcare/param/conversion/video/processing_job_url_builder.rb
uploadcare-ruby-4.3.0 lib/uploadcare/param/conversion/video/processing_job_url_builder.rb
uploadcare-ruby-4.2.0 lib/uploadcare/param/conversion/video/processing_job_url_builder.rb
uploadcare-ruby-3.3.2 lib/uploadcare/param/conversion/video/processing_job_url_builder.rb
uploadcare-ruby-3.3.1 lib/uploadcare/param/conversion/video/processing_job_url_builder.rb
uploadcare-ruby-3.3.0 lib/uploadcare/param/conversion/video/processing_job_url_builder.rb
uploadcare-ruby-3.2.0 lib/uploadcare/param/conversion/video/processing_job_url_builder.rb
uploadcare-ruby-3.1.1 lib/uploadcare/param/conversion/video/processing_job_url_builder.rb
uploadcare-ruby-3.1.0 lib/uploadcare/param/conversion/video/processing_job_url_builder.rb
uploadcare-ruby-3.1.0.pre.rc1 lib/uploadcare/param/conversion/video/processing_job_url_builder.rb