Class: Ffprober::Ffmpeg::Finder
- Inherits:
-
Object
- Object
- Ffprober::Ffmpeg::Finder
- Extended by:
- T::Sig
- Defined in:
- lib/ffprober/ffmpeg/finder.rb
Constant Summary collapse
- SEARCH_PATHS =
T.let(ENV['PATH'], T.nilable(String))
Instance Attribute Summary collapse
-
#executable_name ⇒ Object
readonly
Returns the value of attribute executable_name.
Instance Method Summary collapse
- #executable_name_picker ⇒ Object
- #executable_path ⇒ Object
-
#initialize ⇒ Finder
constructor
A new instance of Finder.
- #path ⇒ Object
- #windows? ⇒ Boolean
Constructor Details
#initialize ⇒ Finder
Returns a new instance of Finder.
14 15 16 17 18 |
# 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 |
Instance Attribute Details
#executable_name ⇒ Object (readonly)
Returns the value of attribute executable_name.
11 12 13 |
# File 'lib/ffprober/ffmpeg/finder.rb', line 11 def executable_name @executable_name end |
Instance Method Details
#executable_name_picker ⇒ Object
33 34 35 36 37 38 39 |
# 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 ⇒ Object
42 43 44 45 46 47 48 |
# 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 ⇒ Object
21 22 23 24 25 |
# File 'lib/ffprober/ffmpeg/finder.rb', line 21 def path raise Ffprober::NoFfprobeFound, 'ffprobe executable not found' if executable_path.nil? @path ||= File.(executable_name, executable_path) end |
#windows? ⇒ Boolean
28 29 30 |
# File 'lib/ffprober/ffmpeg/finder.rb', line 28 def windows? !(RUBY_PLATFORM =~ /(mingw|mswin)/).nil? end |