Sha256: 947e3ff4776af10e25c9f0855b94098e0cbbf3254d1b99ecb020fa62a259fb09

Contents?: true

Size: 786 Bytes

Versions: 3

Compression:

Stored size: 786 Bytes

Contents

require 'picturama'

module Picturama
  class Picture < File
    
    attr_accessor :thumbnail

    def initialize(args)
      super
      @thumbnail = "#{File.dirname(path)}/thumbnails/#{Picturama::config['thumbnail_prefix']}#{File.basename(path)}"
      @resized = "#{File.dirname(path)}/resized/resized_#{File.basename(path)}"
      @metainfo = "#{File.dirname(path)}/resized/resized_#{File.basename(path)}.info"
    end

    def info
      File.read(@metainfo) if File.exists?(@metainfo)
    end

    def has_resized?
      File.exists?(@resized)
    end

    def has_thumbnail?
      File.exists?(@thumbnail) && File.size(@thumbnail) < size
    end

    def remove_assoc
      File.delete(@thumbnail) if has_thumbnail?
      File.delete(@resized) if has_resized?
    end

  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
picturama-0.0.3 lib/picturama/picture.rb
picturama-0.0.2 lib/picturama/picture.rb
picturama-0.0.1 lib/picturama/picture.rb