Class: Florby::Collection
- Inherits:
-
Object
- Object
- Florby::Collection
- Defined in:
- lib/florby/collection.rb
Instance Method Summary collapse
- #all_pages ⇒ Object
- #find(title) ⇒ Object
-
#initialize ⇒ Collection
constructor
A new instance of Collection.
- #pages ⇒ Object
- #titles ⇒ Object
Constructor Details
#initialize ⇒ Collection
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_pages ⇒ Object
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 |
#pages ⇒ Object
16 17 18 |
# File 'lib/florby/collection.rb', line 16 def pages all_pages.reject(&:exclude_from_collections?) end |
#titles ⇒ Object
8 9 10 |
# File 'lib/florby/collection.rb', line 8 def titles @hash.keys end |