Class: Scrapbook::FolderListingViewModel
- Inherits:
-
Object
- Object
- Scrapbook::FolderListingViewModel
- Defined in:
- app/helpers/scrapbook/folder_listing_view_model.rb
Overview
Model to assest list a folder’s contents
Instance Attribute Summary collapse
-
#depth ⇒ Object
readonly
Returns the value of attribute depth.
-
#files ⇒ Object
readonly
Returns the value of attribute files.
-
#folders ⇒ Object
readonly
Returns the value of attribute folders.
-
#pathname ⇒ Object
readonly
Returns the value of attribute pathname.
-
#scrapbook ⇒ Object
readonly
Returns the value of attribute scrapbook.
-
#view ⇒ Object
readonly
Returns the value of attribute view.
Instance Method Summary collapse
- #header_name ⇒ Object
-
#initialize(view, scrapbook, pathname) ⇒ FolderListingViewModel
constructor
A new instance of FolderListingViewModel.
- #parent_display_name ⇒ Object
- #root? ⇒ Boolean
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
#depth ⇒ Object
Returns the value of attribute depth.
6 7 8 |
# File 'app/helpers/scrapbook/folder_listing_view_model.rb', line 6 def depth @depth end |
#files ⇒ Object
Returns the value of attribute files.
6 7 8 |
# File 'app/helpers/scrapbook/folder_listing_view_model.rb', line 6 def files @files end |
#folders ⇒ Object
Returns the value of attribute folders.
6 7 8 |
# File 'app/helpers/scrapbook/folder_listing_view_model.rb', line 6 def folders @folders end |
#pathname ⇒ Object
Returns the value of attribute pathname.
6 7 8 |
# File 'app/helpers/scrapbook/folder_listing_view_model.rb', line 6 def pathname @pathname end |
#scrapbook ⇒ Object
Returns the value of attribute scrapbook.
6 7 8 |
# File 'app/helpers/scrapbook/folder_listing_view_model.rb', line 6 def scrapbook @scrapbook end |
#view ⇒ Object
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_name ⇒ Object
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_name ⇒ Object
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
16 17 18 |
# File 'app/helpers/scrapbook/folder_listing_view_model.rb', line 16 def root? pathname == scrapbook.pages_pathname end |