Sha256: 7264462604486c6613ccc239b20c47fd9ca3298d341091a98239b0b1c4243692
Contents?: true
Size: 1.25 KB
Versions: 6
Compression:
Stored size: 1.25 KB
Contents
module Uploadcare module Rails class Operations def initialize(operations = nil) @operations = operations end def to_s return '' unless @operations result = @operations.map do |operation, options| next unless respond_to?(operation) send(operation, options) end ['-/', result.join('/-/'), '/']. join. gsub(%r{\/+}, '/'). to_s end def format(options) return unless %w(png jpeg).include?(options.to_s) "format/#{ options }" end def progressive(options) return unless %w(yes no).include?(options.to_s) "progressive/#{ options }" end def quality(options) available_options = %w(normal better best lighter lightest) return unless available_options.include?(options.to_s) "quality/#{ options }" end def preview(options) if option = options[/^\d+x\d+$/] "preview/#{ option }" end end def resize(options) if option = options[/^(\d+x\d+)$|^(\d+x)$|^(x\d+)$/] "resize/#{ option }" end end alias_method :size, :resize def inline(options) options end end end end
Version data entries
6 entries across 6 versions & 1 rubygems