class FlickrOfflineGallery::Photoset

Public Class Methods

new(photoset_id, args = {}) click to toggle source
# File lib/flickr_offline_gallery/photoset.rb, line 6
def initialize(photoset_id, args = {})
  @photoset_id = photoset_id
  @output_base_path = args[:output_path] || "."
  eager_load
end

Public Instance Methods

index_page_filename() click to toggle source
# File lib/flickr_offline_gallery/photoset.rb, line 41
def index_page_filename
  path_manager.index_page
end
photos() click to toggle source
# File lib/flickr_offline_gallery/photoset.rb, line 24
def photos
  raise "photoset has more than 500 images and I'm too lazy to handle that right now" if info.pages > 1
  return @photos if @photos
 verbose_puts "Initializing photoset... "
  total_photos = info.photo.size
  @photos = []
  info.photo.each do |raw_response|
    photo = Photo.new(raw_response,
                      :photoset_id => @photoset_id,
                      :path_manager => path_manager)
    @photos << photo
  verbose_puts %(Fetched (#{@photos.size}/#{total_photos}) "#{photo.title}" (#{photo.id}))
  end
  verbose_puts "Finished initializing photoset!"
  @photos
end
slug() click to toggle source
# File lib/flickr_offline_gallery/photoset.rb, line 20
def slug
  title.downcase.tr_s("^a-z0-9", "-")
end
title() click to toggle source
# File lib/flickr_offline_gallery/photoset.rb, line 16
def title
  info.title
end
username() click to toggle source
# File lib/flickr_offline_gallery/photoset.rb, line 12
def username
  info.ownername
end

Private Instance Methods

eager_load() click to toggle source
# File lib/flickr_offline_gallery/photoset.rb, line 51
def eager_load
  info
  photos
end
info() click to toggle source
# File lib/flickr_offline_gallery/photoset.rb, line 56
def info
  @info ||= OpenStruct.new(FlickrAPI.get_photoset(@photoset_id))
end
path_manager() click to toggle source
# File lib/flickr_offline_gallery/photoset.rb, line 47
def path_manager
  PathManager.new(@output_base_path, slug)
end