Module: MPV::Utils
- Defined in:
- lib/mpv_ipc/utils.rb
Overview
Various utility methods for mpv-ipc.
Class Method Summary collapse
- .tmpsock ⇒ Object
-
.which(name) ⇒ String
private
Finds where the given utility is located in the system paths.
Class Method Details
.tmpsock ⇒ Object
15 16 17 |
# File 'lib/mpv_ipc/utils.rb', line 15 def self.tmpsock "mpv-ipc-#{$$}-#{Time.now.strftime("%Y%m%d%N")}-#{rand(36**8).to_s(36)}.sock" end |
.which(name) ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Finds where the given utility is located in the system paths.
10 11 12 13 |
# File 'lib/mpv_ipc/utils.rb', line 10 def self.which(name) paths = ENV["PATH"].split(File::PATH_SEPARATOR).map{ |dir| File.join(dir, name) } paths.find{ |path| File.file?(path) && File.executable?(path) } end |