Class: Ffprober::Ffmpeg::Finder
- Inherits:
-
Object
- Object
- Ffprober::Ffmpeg::Finder
- Defined in:
- lib/ffprober/ffmpeg/finder.rb
Constant Summary collapse
- SEARCH_PATHS =
ENV.fetch('PATH', nil)
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.
10 11 12 13 14 |
# File 'lib/ffprober/ffmpeg/finder.rb', line 10 def initialize @executable_path = nil @executable_name = executable_name_picker @path = nil end |
Instance Attribute Details
#executable_name ⇒ Object (readonly)
Returns the value of attribute executable_name.
8 9 10 |
# File 'lib/ffprober/ffmpeg/finder.rb', line 8 def executable_name @executable_name end |
Instance Method Details
#executable_name_picker ⇒ Object
26 27 28 29 30 31 32 |
# File 'lib/ffprober/ffmpeg/finder.rb', line 26 def executable_name_picker if windows? 'ffprobe.exe' else 'ffprobe' end end |
#executable_path ⇒ Object
34 35 36 37 38 |
# File 'lib/ffprober/ffmpeg/finder.rb', line 34 def executable_path @executable_path ||= SEARCH_PATHS.split(File::PATH_SEPARATOR).detect do |path_to_check| File.executable?(File.join(path_to_check, executable_name)) end end |
#path ⇒ Object
16 17 18 19 20 |
# File 'lib/ffprober/ffmpeg/finder.rb', line 16 def path raise Ffprober::NoFfprobeFound, 'ffprobe executable not found' if executable_path.nil? @path ||= File.(executable_name, executable_path) end |
#windows? ⇒ Boolean
22 23 24 |
# File 'lib/ffprober/ffmpeg/finder.rb', line 22 def windows? !(RUBY_PLATFORM =~ /(mingw|mswin)/).nil? end |