Class: Aruba::Platforms::WindowsWhich
- Inherits:
-
Object
- Object
- Aruba::Platforms::WindowsWhich
- Defined in:
- lib/aruba/platforms/windows_which.rb
Overview
Implement ‘which(command)` for windows
Defined Under Namespace
Classes: AbsoluteOrRelativePathWhich, DefaultWhich, ProgramWhich
Instance Method Summary collapse
-
#call(program, path = ) ⇒ Object
Find fully quallified path for program.
-
#initialize ⇒ WindowsWhich
constructor
A new instance of WindowsWhich.
Constructor Details
#initialize ⇒ WindowsWhich
Returns a new instance of WindowsWhich.
73 74 75 76 77 78 |
# File 'lib/aruba/platforms/windows_which.rb', line 73 def initialize @whiches = [] @whiches << AbsoluteOrRelativePathWhich @whiches << ProgramWhich @whiches << DefaultWhich end |
Instance Method Details
#call(program, path = ) ⇒ Object
Find fully quallified path for program
87 88 89 90 91 92 93 94 |
# File 'lib/aruba/platforms/windows_which.rb', line 87 def call(program, path = ENV["PATH"]) raise ArgumentError, "ENV['PATH'] cannot be empty" if path.nil? || path.empty? program = program.to_s program += windows_executable_extentions if File.extname(program).empty? whiches.find { |w| w.match? program }.new.call(program, path) end |