Class: Slimdown::Folder

Inherits:
Object
  • Object
show all
Defined in:
lib/slimdown/folder.rb

Overview

Internal class for retrieving information about a folder.

Instance Method Summary collapse

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_filesArray<String>

Returns a list of markdown files in the folder.

Returns:

  • (Array<String>)

    List of paths.



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

#pagesArray<Slimdown::Page>

Returns a list of page objects in the folder.

Returns:



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