class Ffprober::Ffmpeg::Finder

Constants

SEARCH_PATHS

Attributes

executable_name[R]

Public Class Methods

new() click to toggle source
# File lib/ffprober/ffmpeg/finder.rb, line 14
def initialize
  @executable_path = T.let(nil, T.nilable(String))
  @executable_name = T.let(executable_name_picker, String)
  @path = T.let(nil, T.nilable(String))
end

Public Instance Methods

executable_name_picker() click to toggle source
# File lib/ffprober/ffmpeg/finder.rb, line 33
def executable_name_picker
  if windows?
    T.let('ffprobe.exe', String)
  else
    T.let('ffprobe', String)
  end
end
executable_path() click to toggle source
# File lib/ffprober/ffmpeg/finder.rb, line 42
def executable_path
  @executable_path ||= begin
    T.must(SEARCH_PATHS).split(File::PATH_SEPARATOR).detect do |path_to_check|
      File.executable?(File.join(path_to_check, executable_name))
    end
  end
end
path() click to toggle source
# File lib/ffprober/ffmpeg/finder.rb, line 21
def path
  raise Ffprober::NoFfprobeFound, 'ffprobe executable not found' if executable_path.nil?

  @path ||= File.expand_path(executable_name, executable_path)
end
windows?() click to toggle source
# File lib/ffprober/ffmpeg/finder.rb, line 28
def windows?
  !(RUBY_PLATFORM =~ /(mingw|mswin)/).nil?
end