Skip to content

Preview Ruby 4.1 is a preview. It can change before the final release. Switch to Ruby 4.0 →

class method

Pathname.glob

(::String | ::Array[::String] pattern, ?::Integer flags) -> ::Array[::Pathname]
(::String | ::Array[::String] pattern, ?::Integer flags) { (::Pathname) -> untyped } -> nil
glob(patterns, base: '.', flags: 0, sort: true) → array_of_pathnames
glob(patterns, base: '.', flags: 0, sort: true) {|pathname| ... } → nil

Selects filesystem entries based on the given keyword arguments base, flags, and sort; see Filename Globbing.

With no block given, returns an array of pathnames, each based on a selected filesystem entry.

With a block given, calls the block with pathnames, each based on a selected filesystem entry.

See also #glob .getwd .mktmpdir .new also in 4.0 · 3.4 · 3.3 · 3.2 · 3.1 · 3.0