Class: Prospectus::Loader
- Inherits:
-
Object
- Object
- Prospectus::Loader
- Defined in:
- lib/prospectus/loader.rb
Overview
Helper for loading prospectus from the current directory
Instance Method Summary collapse
-
#initialize(params = {}) ⇒ Loader
constructor
A new instance of Loader.
- #load ⇒ Object
Constructor Details
#initialize(params = {}) ⇒ Loader
Returns a new instance of Loader.
7 8 9 10 11 |
# File 'lib/prospectus/loader.rb', line 7 def initialize(params = {}) @options = params @file = params[:file] || DEFAULT_FILE @dir = @file + '.d' end |
Instance Method Details
#load ⇒ Object
13 14 15 16 17 18 19 |
# File 'lib/prospectus/loader.rb', line 13 def load return run_file(@options, @file) if File.exist? @file raise("No #{@file}/#{@dir} found") unless Dir.exist? @dir files = Dir.glob(@dir + '/*') raise('No files in ' + @dir) if files.empty? files.map { |x| run_file(@options, x, true) }.flatten end |