Class: Puppeteer::ExecutablePathFinder
- Inherits:
-
Object
- Object
- Puppeteer::ExecutablePathFinder
- Defined in:
- lib/puppeteer/executable_path_finder.rb
Instance Method Summary collapse
- #find_executables_in_path ⇒ Object
- #find_first ⇒ Object
-
#initialize(*executable_names) ⇒ ExecutablePathFinder
constructor
A new instance of ExecutablePathFinder.
Constructor Details
#initialize(*executable_names) ⇒ ExecutablePathFinder
Returns a new instance of ExecutablePathFinder.
3 4 5 |
# File 'lib/puppeteer/executable_path_finder.rb', line 3 def initialize(*executable_names) @executable_names = executable_names end |
Instance Method Details
#find_executables_in_path ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/puppeteer/executable_path_finder.rb', line 7 def find_executables_in_path Enumerator.new do |result| @executable_names.each do |name| # Find the first existing path. paths.each do |path| candidate = File.join(path, name) next unless File.exist?(candidate) result << candidate break end end end end |
#find_first ⇒ Object
21 22 23 |
# File 'lib/puppeteer/executable_path_finder.rb', line 21 def find_first find_executables_in_path.first end |