Class: ImageFile

Inherits:
Object
  • Object
show all
Defined in:
lib/ralbum/album_tree/image_file.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#heightObject (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_poolObject (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_urlObject (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

#sizeObject (readonly)

properties of image



10
11
12
# File 'lib/ralbum/album_tree/image_file.rb', line 10

def size
  @size
end

#src_urlObject (readonly)

paths



52
53
54
# File 'lib/ralbum/album_tree/image_file.rb', line 52

def src_url
  @src_url
end

#widthObject (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



68
69
70
# File 'lib/ralbum/album_tree/image_file.rb', line 68

def breadcrumbs
  @image_pool.breadcrumbs
end

#descriptionObject



45
46
47
# File 'lib/ralbum/album_tree/image_file.rb', line 45

def description
  @image_pool.description
end

#nameObject

properties



41
42
43
# File 'lib/ralbum/album_tree/image_file.rb', line 41

def name
  @image_pool.name
end

#next_page_urlObject



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_rootObject



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_urlObject



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

#relrootObject



59
60
61
# File 'lib/ralbum/album_tree/image_file.rb', line 59

def relroot
  @image_pool.relroot
end

#relroot_with_prefixObject



63
64
65
# File 'lib/ralbum/album_tree/image_file.rb', line 63

def relroot_with_prefix
  @image_pool.relroot_with_prefix
end