class Middleman::AutomaticClowncar::ThumbnailResource

Attributes

output[RW]

Public Class Methods

new(store, path, dimensions, origin, root_path, build_dir, source_dir) click to toggle source
Calls superclass method
# File lib/middleman-automatic-clowncar/thumbnail-resource.rb, line 9
def initialize(store, path, dimensions, origin, root_path, build_dir, source_dir)
  @dimensions = dimensions
  @origin = origin
  @root_path = root_path
  @build_dir = build_dir
  @source_dir = source_dir
  super(store, path, source_dir.to_s)
end

Public Instance Methods

binary?() click to toggle source
# File lib/middleman-automatic-clowncar/thumbnail-resource.rb, line 39
def binary?
  false
end
ignored?() click to toggle source
# File lib/middleman-automatic-clowncar/thumbnail-resource.rb, line 47
def ignored?
  false
end
raw_data() click to toggle source
# File lib/middleman-automatic-clowncar/thumbnail-resource.rb, line 43
def raw_data
  {}
end
render(*args, &block) click to toggle source
# File lib/middleman-automatic-clowncar/thumbnail-resource.rb, line 26
def render(*args, &block)
  output_dir = File.join(@root_path,@build_dir)
  dest_path = File.join(output_dir,@path)
  img = nil
  if Utils.timestamp_current?(@source_dir,@build_dir,@origin) && File.exist?(dest_path)
    img = MiniMagick::Image.open(dest_path)
  else
    img = MiniMagick::Image.open(@origin)
    img.resize(@dimensions) unless @dimensions.blank?
  end
  img.to_blob
end
source_file() click to toggle source
# File lib/middleman-automatic-clowncar/thumbnail-resource.rb, line 22
def source_file
  nil
end
template?() click to toggle source
# File lib/middleman-automatic-clowncar/thumbnail-resource.rb, line 18
def template?
  false
end