You would usually check the $PATH environment variable on *nix systems,
and %Path% on Windows.
In Ruby, that environment variable may be accessed through ENV[‘PATH’].
The path is joined together by a path separator character (on Windows it
is a semi-colon ;' and on *nix it is a colon:’). You can get this
separator in an OS depending way such as File::PATH_SEPARATOR.
I’m sure from here you get the idea. You must split the path into each
directory and perform an iterative operation, verifying the directory
exists and if the program also exists in that directory.