module RBS
  module FileFinder
    # Enumerate RBS files under path
    #
    # When `path` is a file, it yields the path.
    #
    # ```rb
    # FileFinder.each_file(Pathname("foo.rbs")) {} # => yields `foo.rbs`
    # ```
    #
    # When `path` is a directory, it yields all `.rbs` files under the directory, recursively.
    #
    # * Skips files under directory starting with `_`, if `skip_hidden` is `true`
    # * Yields files under directory starting with `_` even if `skip_hidden` is true, when the `_` directory is given explicitly, and `immediate:` is `true`
    #
    # ```rb
    # FileFinder.each_file(Pathname("sig"), skip_hidden: false) {} # => yields all `.rbs` files under `sig`
    # FileFinder.each_file(Pathname("sig"), skip_hidden: true) {} # => yields all `.rbs` files under `sig`, skips `_` directories
    #
    # FileFinder.each_file(Pathname("_hidden"), skip_hidden: true) {}  # => yields all `.rbs` files under `_hidden`, skips other `_` directories
    # ```
    #
    # `immediate` keyword is unused and left for API compatibility.
    # 
    def self?.each_file: (Pathname path, ?immediate: top, skip_hidden: boolish) { (Pathname) -> void } -> void
                        | (Pathname path, ?immediate: top, skip_hidden: boolish) -> Enumerator[Pathname, void]
  end
end
