Class: Aruba::Platforms::UnixWhich
- Inherits:
-
Object
- Object
- Aruba::Platforms::UnixWhich
- Defined in:
- lib/aruba/platforms/unix_which.rb
Overview
Implement which(command)
for UNIX/Linux
Defined Under Namespace
Classes: AbsoluteOrRelativePathWhich, DefaultWhich, ProgramWhich
Instance Method Summary collapse
-
#call(program, path = ) ⇒ Object
Find fully quallified path for program.
-
#initialize ⇒ UnixWhich
constructor
A new instance of UnixWhich.
Constructor Details
#initialize ⇒ UnixWhich
Returns a new instance of UnixWhich.
63 64 65 66 67 68 |
# File 'lib/aruba/platforms/unix_which.rb', line 63 def initialize @whiches = [] @whiches << AbsoluteOrRelativePathWhich @whiches << ProgramWhich @whiches << DefaultWhich end |
Instance Method Details
#call(program, path = ) ⇒ Object
Find fully quallified path for program
77 78 79 80 81 82 |
# File 'lib/aruba/platforms/unix_which.rb', line 77 def call(program, path = ENV['PATH']) raise ArgumentError, "ENV['PATH'] cannot be empty" if path.nil? || path.empty? program = program.to_s whiches.find { |w| w.match? program }.new.call(program, path) end |