Module: Rya::CoreExtensions::File
- Defined in:
- lib/rya/core_extensions.rb
Instance Method Summary collapse
-
#command?(cmd) ⇒ Boolean, String
Check if a string specifies an executable command on the PATH.
Instance Method Details
#command?(cmd) ⇒ Boolean, String
Note:
Check if a string specifies an executable command on the PATH.
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/rya/core_extensions.rb', line 37 def command? cmd return cmd if Object::File.executable? cmd exts = ENV["PATHEXT"] ? ENV["PATHEXT"].split(";") : [""] ENV["PATH"].split(Object::File::PATH_SEPARATOR).each do |path| exts.each do |ext| exe = Object::File.join path, "#{cmd}#{ext}" return exe if Object::File.executable?(exe) && !Object::File.directory?(exe) end end nil end |