Class: Florby::Collection

Inherits:
Object
  • Object
show all
Defined in:
lib/florby/collection.rb

Instance Method Summary collapse

Constructor Details

#initializeCollection

Returns a new instance of Collection.



3
4
5
6
# File 'lib/florby/collection.rb', line 3

def initialize
  files = Dir.glob(File.join(Dir.pwd, 'src', '*.md'))
  @hash = files.map { |file| [File.basename(file).gsub(/\.md$/, ''), Page.new(file: file)] }.to_h
end

Instance Method Details

#all_pagesObject



12
13
14
# File 'lib/florby/collection.rb', line 12

def all_pages
  @hash.values.sort_by(&:created).reverse
end

#find(title) ⇒ Object



20
21
22
# File 'lib/florby/collection.rb', line 20

def find(title)
  @hash[title]
end

#pagesObject



16
17
18
# File 'lib/florby/collection.rb', line 16

def pages
  all_pages.reject(&:exclude_from_collections?)
end

#titlesObject



8
9
10
# File 'lib/florby/collection.rb', line 8

def titles
  @hash.keys
end