class Utopia::Gallery::Container
Attributes
filter[R]
path[R]
root[R]
Public Class Methods
new(root, path, filter: /(jpe?g|png)$/i)
click to toggle source
# File lib/utopia/gallery/container.rb, line 30 def initialize(root, path, filter: /(jpe?g|png)$/i) @root = root @path = path @filter = filter end
Public Instance Methods
each() { |media(path, media_metadata || {})| ... }
click to toggle source
# File lib/utopia/gallery/container.rb, line 40 def each return to_enum unless block_given? gallery_metadata = load_metadata entries.each do |name| path = File.join(@path, name) media_metadata = gallery_metadata.delete(name) yield Media.new(path, media_metadata || {}) end end
Private Instance Methods
entries()
click to toggle source
# File lib/utopia/gallery/container.rb, line 59 def entries Dir.entries(full_path).select{|name| name =~ @filter} end
full_path()
click to toggle source
# File lib/utopia/gallery/container.rb, line 55 def full_path File.join(@root, @path) end
load_metadata()
click to toggle source
# File lib/utopia/gallery/container.rb, line 63 def load_metadata metadata_path = File.join(full_path, 'gallery.yaml') if File.exist? metadata_path return YAML::load(File.read(metadata_path)) else return {} end end