Module: Paths

Defined in:
lib/rust/syntax/paths.rb

Overview

Created by me on 2011-12-07.

Copyright (c) 2011. All pwnage reserved.

$path = [‘/bin’, ‘/usr/bin’, ‘/usr/local/bin’]

Class Method Summary collapse

Class Method Details

.find_path(file) ⇒ Object



23
24
25
26
# File 'lib/rust/syntax/paths.rb', line 23

def find_path(file)
  return Dir.pwd + file unless on_path? file
  return File.join(on_path?(file), file)
end

.on_path?(file) ⇒ Boolean

linear search checks if file if on path

Returns:

  • (Boolean)


16
17
18
19
20
21
# File 'lib/rust/syntax/paths.rb', line 16

def on_path? file
  $path.each do |f|
    return f if Dir[File.join(f, file)]
  end
  false
end