Class: Servel::GalleryView

Inherits:
Object
  • Object
show all
Defined in:
lib/servel/gallery_view.rb

Instance Method Summary collapse

Constructor Details

#initialize(url_path, fs_path) ⇒ GalleryView

Returns a new instance of GalleryView.



2
3
4
5
# File 'lib/servel/gallery_view.rb', line 2

def initialize(url_path, fs_path)
  @url_path = url_path
  @fs_path = fs_path
end

Instance Method Details

#localsObject



11
12
13
14
15
16
17
18
19
# File 'lib/servel/gallery_view.rb', line 11

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

#render(haml_context) ⇒ Object



7
8
9
# File 'lib/servel/gallery_view.rb', line 7

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

#sort_paths(paths) ⇒ Object



21
22
23
# File 'lib/servel/gallery_view.rb', line 21

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