Class: Alki::Reload::LoadPathHandler

Inherits:
Object
  • Object
show all
Defined in:
lib/alki/reload/load_path_handler.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(root_dir, dirs) ⇒ LoadPathHandler

Returns a new instance of LoadPathHandler.



4
5
6
# File 'lib/alki/reload/load_path_handler.rb', line 4

def initialize(root_dir,dirs)
  @dirs = dirs.map{|d| File.join(root_dir,d,'')}.select{|d| Dir.exist? d }
end

Instance Attribute Details

#dirsObject (readonly)

Returns the value of attribute dirs.



8
9
10
# File 'lib/alki/reload/load_path_handler.rb', line 8

def dirs
  @dirs
end

Instance Method Details

#handle_path(path) ⇒ Object



10
11
12
13
14
15
16
17
# File 'lib/alki/reload/load_path_handler.rb', line 10

def handle_path(path)
  @dirs.each do |dir|
    if path.start_with? dir
      return path[dir.size..-1].chomp('.rb')
    end
  end
  nil
end