Module: Daigaku::Loadable

Included in:
Daigaku::Loading::Chapters, Daigaku::Loading::Courses, Daigaku::Loading::Units
Defined in:
lib/daigaku/loadable.rb

Instance Method Summary collapse

Instance Method Details

#load(path) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/daigaku/loadable.rb', line 3

def load(path)
  return [] unless Dir.exist?(path)

  dirs = Dir.entries(path).select do |entry|
    !entry.match(/\./)
  end

  dirs.sort.map do |dir|
    dir_path   = File.join(path, dir)
    module_name = demodulize(to_s)
    class_name = singularize(module_name)
    daigaku_class(class_name).new(dir_path)
  end
end