class Slimdown::Folder

Internal class for retrieving information about a folder.

Public Class Methods

new(absolute_path) click to toggle source
# File lib/slimdown/folder.rb, line 4
def initialize(absolute_path)
  @absolute_path = absolute_path
end

Public Instance Methods

markdown_files() click to toggle source

Returns a list of markdown files in the folder.

@return [Array<String>] List of paths.

# 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() click to toggle source

Returns a list of page objects in the folder.

@return [Array<Slimdown::Page>] List of pages.

# 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