Module: MPV::Utils

Defined in:
lib/mpv_ipc/utils.rb

Overview

Various utility methods for mpv-ipc.

Class Method Summary collapse

Class Method Details

.tmpsockObject



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.

Parameters:

  • name (String)

    name of the utility to find

Returns:

  • (String)

    full path of the utility



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