Class: JLDrill::LoadPath

Inherits:
Object
  • Object
show all
Defined in:
lib/jldrill/model/LoadPath.rb

Overview

Resolves files based on a load path

Instance Method Summary collapse

Constructor Details

#initializeLoadPath

Returns a new instance of LoadPath.



7
8
9
# File 'lib/jldrill/model/LoadPath.rb', line 7

def initialize()
    @loadPath = []
end

Instance Method Details

#add(path) ⇒ Object

Add a path to the load path. This path will be added to the end of the load path. A path equalling nil will not be added



32
33
34
35
36
# File 'lib/jldrill/model/LoadPath.rb', line 32

def add(path)
    if !path.nil?
        @loadPath.push(path)
    end
end

#empty?Boolean

Returns true if the load path contains no entries

Returns:

  • (Boolean)


12
13
14
# File 'lib/jldrill/model/LoadPath.rb', line 12

def empty?()
    return @loadPath.empty?
end

#find(filename) ⇒ Object

Find a file in the load path. Returns nil if no such file exists, or the path the the file highest up on the load path.



19
20
21
22
23
24
25
26
27
# File 'lib/jldrill/model/LoadPath.rb', line 19

def find(filename)
    retVal = @loadPath.find do |path|
        File.exists?(File.join(path, filename))
    end
    if !retVal.nil?
        retVal = File.join(retVal, filename)
    end
    return retVal
end

#to_sObject

Return a string representation of the load path. This is essentially the paths separated by colons.



40
41
42
# File 'lib/jldrill/model/LoadPath.rb', line 40

def to_s
    return @loadPath.join(":")
end