Sha256: a7f14d22969728607682a08d9ec74aed5f8ee5dd9b9b92cf14e6337620a67a28

Contents?: true

Size: 936 Bytes

Versions: 1

Compression:

Stored size: 936 Bytes

Contents

# See Bloggit::Media
module Bloggit
  
  # = Media
  class Media
    
    attr_reader :site, :filename, :ext, :full_path, :relative_path, :name, :size, :dimensions
    
    def initialize(path, site)
      @site = site
      @full_path = path
      @relative_path = path.gsub(File.join(site.base_path, 'media', ''), '')
      # Read file info and set Media properties...
      @filename = File.basename(path)
      @ext = File.extname(path)
      # TODO: name, size, dimensions
    end
    
    def thumbnail_path(size=nil)
    end

    def create_thumbnail(size=nil)
    end
    
    def permalink
      "media/#{@relative_path}"
    end
    
    class << self
      #private :new
      
      # Creates a Media object from an image on the filesystem
      def from_file(path, site) 
        path = File.expand_path(path)
        raise "File must exist" unless File.exists?( path )
        new( path, site )
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
bloggit-1.0.7 lib/bloggit/media.rb