Class: Puppeteer::ExecutablePathFinder

Inherits:
Object
  • Object
show all
Defined in:
lib/puppeteer/executable_path_finder.rb

Instance Method Summary collapse

Constructor Details

#initialize(*executable_names) ⇒ ExecutablePathFinder

Returns a new instance of ExecutablePathFinder.

Parameters:

  • executable_names (Array<String>)

    executable file names to find.



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_pathObject



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_firstObject



21
22
23
# File 'lib/puppeteer/executable_path_finder.rb', line 21

def find_first
  find_executables_in_path.first
end