module Photish::Gallery::Traits::Albumable

Public Instance Methods

albums() click to toggle source
# File lib/photish/gallery/traits/albumable.rb, line 5
def albums
  @albums ||= Dir.entries(path)
                 .reject { |file| ['.', '..'].include?(file)  }
                 .map    { |file| File.join(path, file)       }
                 .reject { |file| !Dir.exist?(file)           }
                 .map    { |file| album_class.new(self, file) }
end
all_albums() click to toggle source
# File lib/photish/gallery/traits/albumable.rb, line 20
def all_albums
  @all_albums ||= albums.map { |album| [album] + album.all_albums }
                        .flatten
end
all_entities() click to toggle source
# File lib/photish/gallery/traits/albumable.rb, line 13
def all_entities
  all_albums +
    all_photos +
    all_pages +
    all_images
end
all_images() click to toggle source
# File lib/photish/gallery/traits/albumable.rb, line 37
def all_images
  @all_images ||= all_photos.map(&:images)
                            .flatten
end
all_pages() click to toggle source
# File lib/photish/gallery/traits/albumable.rb, line 31
def all_pages
  @all_pages ||= all_albums.map(&:pages)
                            .concat(self.try(:pages) || [])
                            .flatten
end
all_photos() click to toggle source
# File lib/photish/gallery/traits/albumable.rb, line 25
def all_photos
  @all_photos ||= all_albums.map(&:photos)
                            .concat(self.try(:photos) || [])
                            .flatten
end