Method: YARD::Templates::Template::ClassMethods#find_nth_file

Defined in:
lib/yard/templates/template.rb

#find_nth_file(basename, index = 1) ⇒ String

Searches for the nth file (where n = index) identified by basename in the template’s path and any mixed in template paths.

Parameters:

  • basename (String)

    the filename to search for

  • index (Fixnum) (defaults to: 1)

    the nth existing file to return

Returns:

  • (String)

    the full path of the nth file on disk with filename basename in one of the template paths



109
110
111
112
113
114
115
116
117
118
119
120
# File 'lib/yard/templates/template.rb', line 109

def find_nth_file(basename, index = 1)
  n = 1
  full_paths.each do |path|
    file = File.join(path, basename)
    if File.file?(file)
      return file if index == n
      n += 1
    end
  end

  nil
end