Class: FilesLoader::Collector

Inherits:
Object
  • Object
show all
Defined in:
lib/files_loader/collector.rb

Instance Method Summary collapse

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

#loadObject



24
25
26
# File 'lib/files_loader/collector.rb', line 24

def load
  @files.each { |file| require file }
end

#runObject



9
10
11
12
# File 'lib/files_loader/collector.rb', line 9

def run
  fetch(@path)
  load
end