Class: ImageFile
- Inherits:
-
Object
- Object
- ImageFile
- Defined in:
- lib/ralbum/album_tree/image_file.rb
Instance Attribute Summary collapse
-
#height ⇒ Object
readonly
Returns the value of attribute height.
-
#image_pool ⇒ Object
readonly
Returns the value of attribute image_pool.
-
#page_url ⇒ Object
readonly
url of html page displaying the image.
-
#size ⇒ Object
readonly
properties of image.
-
#src_url ⇒ Object
readonly
paths.
-
#width ⇒ Object
readonly
Returns the value of attribute width.
Instance Method Summary collapse
- #breadcrumbs ⇒ Object
- #description ⇒ Object
-
#initialize(image_pool, local_path, src_url, page_url) ⇒ ImageFile
constructor
page_url is the url of html page relative to the webroot f.e.
-
#name ⇒ Object
properties.
- #next_page_url ⇒ Object
- #page_url_from_root ⇒ Object
- #prev_page_url ⇒ Object
- #relroot ⇒ Object
- #relroot_with_prefix ⇒ Object
Constructor Details
#initialize(image_pool, local_path, src_url, page_url) ⇒ ImageFile
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
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/ralbum/album_tree/image_file.rb', line 20 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 |
Instance Attribute Details
#height ⇒ Object (readonly)
Returns the value of attribute height.
12 13 14 |
# File 'lib/ralbum/album_tree/image_file.rb', line 12 def height @height end |
#image_pool ⇒ Object (readonly)
Returns the value of attribute image_pool.
7 8 9 |
# File 'lib/ralbum/album_tree/image_file.rb', line 7 def image_pool @image_pool end |
#page_url ⇒ Object (readonly)
url of html page displaying the image
53 54 55 |
# File 'lib/ralbum/album_tree/image_file.rb', line 53 def page_url @page_url end |
#size ⇒ Object (readonly)
properties of image
10 11 12 |
# File 'lib/ralbum/album_tree/image_file.rb', line 10 def size @size end |
#src_url ⇒ Object (readonly)
paths
52 53 54 |
# File 'lib/ralbum/album_tree/image_file.rb', line 52 def src_url @src_url end |
#width ⇒ Object (readonly)
Returns the value of attribute width.
11 12 13 |
# File 'lib/ralbum/album_tree/image_file.rb', line 11 def width @width end |
Instance Method Details
#breadcrumbs ⇒ Object
68 69 70 |
# File 'lib/ralbum/album_tree/image_file.rb', line 68 def @image_pool. end |
#description ⇒ Object
45 46 47 |
# File 'lib/ralbum/album_tree/image_file.rb', line 45 def description @image_pool.description end |
#name ⇒ Object
properties
41 42 43 |
# File 'lib/ralbum/album_tree/image_file.rb', line 41 def name @image_pool.name end |
#next_page_url ⇒ Object
80 81 82 83 84 85 86 |
# File 'lib/ralbum/album_tree/image_file.rb', line 80 def next_page_url if @image_pool.next @image_pool.next.default_image_file.page_url else nil end end |
#page_url_from_root ⇒ Object
55 56 57 |
# File 'lib/ralbum/album_tree/image_file.rb', line 55 def page_url_from_root @image_pool.path + "/" + page_url end |
#prev_page_url ⇒ Object
72 73 74 75 76 77 78 |
# File 'lib/ralbum/album_tree/image_file.rb', line 72 def prev_page_url if @image_pool.prev @image_pool.prev.default_image_file.page_url else nil end end |
#relroot ⇒ Object
59 60 61 |
# File 'lib/ralbum/album_tree/image_file.rb', line 59 def relroot @image_pool.relroot end |
#relroot_with_prefix ⇒ Object
63 64 65 |
# File 'lib/ralbum/album_tree/image_file.rb', line 63 def relroot_with_prefix @image_pool.relroot_with_prefix end |