Class: Scrapbook::FolderListingViewModel

Inherits:
Object
  • Object
show all
Defined in:
app/helpers/scrapbook/folder_listing_view_model.rb

Overview

Model to assest list a folder’s contents

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(view, scrapbook, pathname) ⇒ FolderListingViewModel

Returns a new instance of FolderListingViewModel.



8
9
10
11
12
13
14
# File 'app/helpers/scrapbook/folder_listing_view_model.rb', line 8

def initialize(view, scrapbook, pathname)
  self.view = view
  self.scrapbook = scrapbook
  self.pathname = pathname.directory? ? pathname : pathname.dirname
  self.depth = calculate_depth
  self.folders, self.files = split_files_and_folders
end

Instance Attribute Details

#depthObject

Returns the value of attribute depth.



6
7
8
# File 'app/helpers/scrapbook/folder_listing_view_model.rb', line 6

def depth
  @depth
end

#filesObject

Returns the value of attribute files.



6
7
8
# File 'app/helpers/scrapbook/folder_listing_view_model.rb', line 6

def files
  @files
end

#foldersObject

Returns the value of attribute folders.



6
7
8
# File 'app/helpers/scrapbook/folder_listing_view_model.rb', line 6

def folders
  @folders
end

#pathnameObject

Returns the value of attribute pathname.



6
7
8
# File 'app/helpers/scrapbook/folder_listing_view_model.rb', line 6

def pathname
  @pathname
end

#scrapbookObject

Returns the value of attribute scrapbook.



6
7
8
# File 'app/helpers/scrapbook/folder_listing_view_model.rb', line 6

def scrapbook
  @scrapbook
end

#viewObject

Returns the value of attribute view.



6
7
8
# File 'app/helpers/scrapbook/folder_listing_view_model.rb', line 6

def view
  @view
end

Instance Method Details

#header_nameObject



27
28
29
# File 'app/helpers/scrapbook/folder_listing_view_model.rb', line 27

def header_name
  root? ? scrapbook.name : pathname.basename.to_s
end

#parent_display_nameObject



20
21
22
23
24
25
# File 'app/helpers/scrapbook/folder_listing_view_model.rb', line 20

def parent_display_name
  return nil if root?
  return scrapbook.name if pathname.parent == scrapbook.pages_pathname

  pathname.parent.basename.to_s
end

#root?Boolean

Returns:

  • (Boolean)


16
17
18
# File 'app/helpers/scrapbook/folder_listing_view_model.rb', line 16

def root?
  pathname == scrapbook.pages_pathname
end