Sha256: 277c7451b4cc40829deaa0a6c44611ce31104a47ca2b413b0070092258458678

Contents?: true

Size: 935 Bytes

Versions: 1

Compression:

Stored size: 935 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.3 lib/bloggit/media.rb