Method: Library#find
- Defined in:
- lib/library.rb
#find(pathname, options = {}) ⇒ Feature? Also known as: include?
Does a library contain a relative file within it’s loadpath. If so return the libary file object for it, otherwise false.
Note that this method was designed to maximize speed.
297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 |
# File 'lib/library.rb', line 297 def find(pathname, ={}) main = [:main] #legacy = options[:legacy] suffix = [:suffix] || [:suffix].nil? #suffix = false if options[:load] suffix = false if SUFFIXES.include?(::File.extname(pathname)) if suffix loadpath.each do |lpath| SUFFIXES.each do |ext| f = ::File.join(location, lpath, pathname + ext) return feature(lpath, pathname, ext) if ::File.file?(f) end end #unless legacy legacy_loadpath.each do |lpath| SUFFIXES.each do |ext| f = ::File.join(location, lpath, pathname + ext) return feature(lpath, pathname, ext) if ::File.file?(f) end end unless main else loadpath.each do |lpath| f = ::File.join(location, lpath, pathname) return feature(lpath, pathname) if ::File.file?(f) end #unless legacy legacy_loadpath.each do |lpath| f = ::File.join(location, lpath, pathname) return feature(lpath, pathname) if ::File.file?(f) end unless main end nil end |