Module: MPV::Utils

Defined in:
lib/mpv/utils.rb

Overview

Various utility methods for ruby-mpv.

Class Method Summary collapse

Class Method Details

.tmpsockObject



16
17
18
19
# File 'lib/mpv/utils.rb', line 16

def self.tmpsock
  t = Time.now.strftime("%Y%m%d")
  "mpv#{t}-#{$$}-#{rand(0x100000000).to_s(36)}.sock"
end

.which?(util) ⇒ Boolean

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.

Tests whether the given utility is available in the system path.

Parameters:

  • util (String)

    the utility to test

Returns:

  • (Boolean)

    whether or not the utility is available



10
11
12
13
14
# File 'lib/mpv/utils.rb', line 10

def self.which?(util)
  ENV["PATH"].split(File::PATH_SEPARATOR).any? do |path|
    File.executable?(File.join(path, util))
  end
end