Class: Backframe::ImageCache::Asset

Inherits:
Object
  • Object
show all
Defined in:
lib/backframe/image_cache/lib/asset.rb

Instance Method Summary collapse

Constructor Details

#initialize(filepath, conversions) ⇒ Asset

Returns a new instance of Asset.



9
10
11
12
# File 'lib/backframe/image_cache/lib/asset.rb', line 9

def initialize(filepath, conversions)
  @filepath = filepath
  @conversions = conversions
end

Instance Method Details

#processObject



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/backframe/image_cache/lib/asset.rb', line 14

def process
  normalized = Backframe::ImageCache::Conversions.new(conversions)
  if filepath.present?
    fullpath = fullpath(filepath)
    content_type = content_type(filepath)
    data = download(fullpath)
    oriented = auto_orient(data)
    command = expand(normalized)
    converted = execute(oriented, command)
  else
    converted = default_asset
  end
  compressed = compress(converted)
  OpenStruct.new({ :success => true, :data => compressed, :content_type => content_type })
end