class CarrierWave::Blitline::ImageVersion

An instance of an ImageVersion for Blitline API.

 When the process() version is called in an Uploader class, we store the version
   name, and the block to create that version as an ImageVersion

 So, a 'small' image version that's resized to fit 200x200 looks like:

   ImageVersion.new("small") do
     process :resize_to_fit => [200, 200]
   end

NOTE: We need a 'default' image version too. This is created automatically, and
  the name for the version is 'nil'.

Attributes

name[R]
primary_function[RW]
secondary_functions[RW]

Public Class Methods

new(name = nil, &block) click to toggle source
# File lib/carrierwave/blitline/image_version.rb, line 24
def initialize(name = nil, &block)
  @name                = name
  @primary_function    = nil
  @secondary_functions = []
  instance_exec(&block) if block_given?
end

Public Instance Methods

primary_function_name() click to toggle source

Returns a String of the name of the primary function for this version

(default: "no_op")
# File lib/carrierwave/blitline/image_version.rb, line 56
def primary_function_name
  primary_function.nil? ? "no_op" : primary_function.name
end
primary_function_params() click to toggle source

Returns a Hash of the params of the primary function for this

version (default: {})
# File lib/carrierwave/blitline/image_version.rb, line 62
def primary_function_params
  primary_function.nil? ? {} : primary_function.params
end
process(function_hash) click to toggle source

Hijacks the process() method that's called within a CarrierWave uploader.

Example:

 version :thumb do
   process :crop            => [10, 10, 200, 200]
   process :process_to_fill => [500, 500]
 end

This stores the crop function as the "primary" function, and the process_to_fill
  function as a "secondary" function.
# File lib/carrierwave/blitline/image_version.rb, line 42
def process(function_hash)
  function_hash   = { function_hash => nil } unless function_hash.is_a?(Hash)
  function_name   = function_hash.keys.first
  function_params = function_hash.values.first
  function = Function.new(function_name, function_params)
  if primary_function.nil?
    self.primary_function    = function
  else
    secondary_functions << function
  end
end