# ralbum require 'treevisitor/leaf_node' # # ImagePool e' creata da una PhotoItem identificata da un md5 # ImagePool ha una 'key' con cui viene identificata nel catalog # ha un 'title' che e' anche il 'name' del LeafNode # ha una 'description' della photo che rappresenta # class ImagePool < LeafNode # include ObjectWithProperties # # md5 of original photo # attr_reader :md5 # # key (number) assigned by catalog for the original photo # attr_reader :key # title -> name attr_reader :description def initialize( album, md5, key, title, description ) super( title, album ) @md5 = md5 @key = key @album = album @description = description @images = {} end ############################################################################ # paths def relroot parent.relroot end def relroot_with_prefix parent.relroot_with_prefix end def breadcrumbs parent.breadcrumbs end ############################################################################ # images management def image( type, image_file = nil) if image_file @images[ type ] = image_file end res = @images[ type ] if res.nil? raise "image type '#{type}' of photo '#{name}' not found" end res end def default_image_file image("default") end def thumb image("thumb") end ############################################################################ def to_s str = "ip: #{name.to_s} -#{@images.length}-" @images.each_key { |key| str += key.to_s } str end end