class Pixhibitee::App

Public Instance Methods

collect_files(base_path) { |path| ... } click to toggle source
# File lib/pixhibitee/app.rb, line 29
def collect_files(base_path)
  expanded_path = File.expand_path(base_path)
  paths = Dir.glob("#{expanded_path}/*").select do |path|
    yield(path)
  end
  paths.map do |path|
    format_link(path, expanded_path, base_path)
  end
end
collect_image_files(base_path) click to toggle source
# File lib/pixhibitee/app.rb, line 17
def collect_image_files(base_path)
  collect_files(base_path) do |path|
    displayable?(path)
  end
end
collect_sub_directories(base_path) click to toggle source
# File lib/pixhibitee/app.rb, line 23
def collect_sub_directories(base_path)
  collect_files(base_path) do |path|
    File.directory?(path)
  end
end
displayable?(path) click to toggle source
# File lib/pixhibitee/app.rb, line 39
def displayable?(path)
  mime_type = MIME::Types.type_for(path)[0]
  return false unless mime_type
  mime_type.media_type == "image"
end