Sha256: 7f55ca07755b30c89f0bbe8bdbdf9b9631b1dab3037360dcd853521c04b0f957

Contents?: true

Size: 1.5 KB

Versions: 1

Compression:

Stored size: 1.5 KB

Contents

# treevisitor
require 'treevisitor/tree_node'

#
# subalbum -> childs
# leaves -> photos o image_pools
#
class Album < TreeNode
  
  attr_reader   :key
  attr_reader   :description

  def initialize( parent, key, title, description )
    super( title, parent )

    @key = key
    @description = description
    @default_image_pool = nil
  end

  ############################################################################
  # paths
  #

  def relroot
    "../" * depth
  end
  
  def relroot_with_prefix
    if root.prefix_path
      root.prefix_path + relroot
    else
      relroot
    end
  end

  def page_url_from_root
    File.join( path, "index.html" ) 
  end
  
  def page_url
    File.join( name, "index.html" )       
  end

  def breadcrumbs
    h = { :title => name, :path => page_url_from_root }
    if parent
      parent.breadcrumbs <<  h
    else
      [ h ]
    end
  end

  ###########################################################################

  def default_image_pool
    return @default_image_pool unless @default_image_pool.nil?
    if leaves.length > 0
      @default_image_pool = leaves[0]
    elsif childs.length > 0
      @default_image_pool = childs[0].default_image_pool
    end
    if @default_image_pool.nil?
      msg =  "cannot determine defaultphoto for album #{title} #{reldir} #{@leaves.length} #{@childs.length}"
      raise msg
    end
    @default_image_pool
  end

  def to_s
    "a: #{name.to_s}"
  end
  
end 

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
gf-ralbum-0.0.5 lib/ralbum/album_tree/album.rb