Class: FilesLoader::Collector
- Inherits:
-
Object
- Object
- FilesLoader::Collector
- Defined in:
- lib/files_loader/collector.rb
Instance Method Summary collapse
- #fetch(path) ⇒ Object
-
#initialize(path) ⇒ Collector
constructor
A new instance of Collector.
- #load ⇒ Object
- #run ⇒ Object
Constructor Details
#initialize(path) ⇒ Collector
Returns a new instance of Collector.
4 5 6 7 |
# File 'lib/files_loader/collector.rb', line 4 def initialize(path) @path = path @files = [] end |
Instance Method Details
#fetch(path) ⇒ Object
14 15 16 17 18 19 20 21 22 |
# File 'lib/files_loader/collector.rb', line 14 def fetch(path) Dir[ path + '/*' ].each do|file| if File.directory?(file) fetch(file) elsif file =~ /.rb$/ @files << file end end end |
#load ⇒ Object
24 25 26 |
# File 'lib/files_loader/collector.rb', line 24 def load @files.each { |file| require file } end |
#run ⇒ Object
9 10 11 12 |
# File 'lib/files_loader/collector.rb', line 9 def run fetch(@path) load end |