Browse | Submit A New Snippet | Create A Package

 

ruby which

Type:
Function
Category:
File Management
License:
GNU General Public License
Language:
Ruby
 
Description:
which command ruby equivalent

Versions Of This Snippet::

Bruno Carnazzi
Snippet ID Download Version Date Posted Author Delete
801.02005-03-21 09:26Bruno Carnazzi

Download a raw-text version of this code by clicking on "Download Version"

 


Latest Snippet Version: :1.0

def which(name)
   ENV['PATH'].split(':').map { |p| File.join p, name }.find { |p| File.file? p and File.executable? p }
end

		

Submit a new version

You can submit a new version of this snippet if you have modified it and you feel it is appropriate to share with others..