Sha256: afb0e8c3cdd6abd504d957723848587b349019ba3b403ae17c3320aab0b45601
Contents?: true
Size: 1.9 KB
Versions: 1
Compression:
Stored size: 1.9 KB
Contents
# gems require 'rubygems' require 'RMagick' class ImageFile attr_reader :image_pool # properties of image attr_reader :size attr_reader :width attr_reader :height # # page_url is the url of html page relative to the webroot f.e. "img_88.html" # used to link html pages # url is the name of image f.e. "img_88.jpg" # used in the src=<...> of the image tag # def initialize( image_pool, local_path, src_url, page_url ) @image_pool = image_pool @src_url = src_url @page_url = page_url if not File.exist?(local_path) raise RAlbumException.new "file '#{local_path}' not exist" end if File.directory?(local_path) raise RAlbumException.new "expected '#{local_path}' as file but it is a directory" end image = Magick::Image::read(local_path).first @width = image.columns @height = image.rows @size = image.filesize / 1024 end ############################################################################# # properties # def name @image_pool.name end def description @image_pool.description end ############################################################################# # paths attr_reader :src_url # path where is the image attr_reader :page_url # url of html page displaying the image def page_url_from_root @image_pool.path + "/" + page_url end def relroot @image_pool.relroot end def relroot_with_prefix @image_pool.relroot_with_prefix end def breadcrumbs @image_pool.breadcrumbs end def prev_page_url if @image_pool.prev @image_pool.prev.default_image_file.page_url else nil end end def next_page_url if @image_pool.next @image_pool.next.default_image_file.page_url else nil end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
gf-ralbum-0.0.5 | lib/ralbum/album_tree/image_file.rb |