Class: MdRecord::CategorizedLoader
- Inherits:
-
Object
- Object
- MdRecord::CategorizedLoader
- Defined in:
- lib/md_record/categorized_loader.rb
Instance Method Summary collapse
-
#initialize(path:, categories:) ⇒ CategorizedLoader
constructor
A new instance of CategorizedLoader.
- #load ⇒ Object
Constructor Details
#initialize(path:, categories:) ⇒ CategorizedLoader
Returns a new instance of CategorizedLoader.
5 6 7 8 |
# File 'lib/md_record/categorized_loader.rb', line 5 def initialize(path:, categories:) @path = Pathname.new(path). @categories = categories end |
Instance Method Details
#load ⇒ Object
10 11 12 13 14 15 16 17 18 |
# File 'lib/md_record/categorized_loader.rb', line 10 def load @categories.keys.flat_map do |category| if category_path(category).directory? category_files(category).map { |file| yield file, category } else [] end end end |