Sha256: be968278ac1af0a910212f726b73e9800d2e8cd9f78540c76779e55e7119c3cf

Contents?: true

Size: 518 Bytes

Versions: 1

Compression:

Stored size: 518 Bytes

Contents

class Servel::GalleryView
  def initialize(url_path, fs_path)
    @url_path = url_path
    @fs_path = fs_path
  end

  def render(haml_context)
    haml_context.render('gallery.haml', locals)
  end

  def locals
    image_paths = @fs_path.children.select { |child| child.image? }

    {
      url_path: @url_path,
      fs_path: @fs_path,
      image_paths: sort_paths(image_paths)
    }
  end

  def sort_paths(paths)
    Naturalsorter::Sorter.sort(paths.map(&:to_s), true).map { |path| Pathname.new(path) }
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
servel-0.1.0 lib/servel/gallery_view.rb