Class: Slimdown::Folder
- Inherits:
-
Object
- Object
- Slimdown::Folder
- Defined in:
- lib/slimdown/folder.rb
Overview
Internal class for retrieving information about a folder.
Instance Method Summary collapse
-
#initialize(absolute_path) ⇒ Folder
constructor
A new instance of Folder.
-
#markdown_files ⇒ Array<String>
Returns a list of markdown files in the folder.
-
#pages ⇒ Array<Slimdown::Page>
Returns a list of page objects in the folder.
Constructor Details
#initialize(absolute_path) ⇒ Folder
Returns a new instance of Folder.
4 5 6 |
# File 'lib/slimdown/folder.rb', line 4 def initialize(absolute_path) @absolute_path = absolute_path end |
Instance Method Details
#markdown_files ⇒ Array<String>
Returns a list of markdown files in the folder.
11 12 13 14 15 16 |
# File 'lib/slimdown/folder.rb', line 11 def markdown_files return [] unless Dir.exists? @absolute_path dir = Dir.new @absolute_path files = dir.entries.grep(/\.md\z/i) end |
#pages ⇒ Array<Slimdown::Page>
Returns a list of page objects in the folder.
21 22 23 24 25 26 27 28 29 30 |
# File 'lib/slimdown/folder.rb', line 21 def pages pages = [] markdown_files.each do |file| path = "#{@absolute_path}/#{file}" pages << Slimdown::Page.new(path) end pages end |