class Finder
- Finder
- Reference
- Object
Overview
Inspired by the find command, this helps you find files and folders recursively in Crystal
Defined in:
finder.crConstructors
- .new(root : String, rules : Array(FinderRule))
- .new(root : String, rule : FinderRule)
- .new(rules : Array(FinderRule))
- .new(rule : FinderRule)
- .new(root = Dir.current)
Instance Method Summary
-
#dirs : Array(String)
gives you all the directories that exist recursively as Array(String)
- #dirs(&block : String -> )
-
#each(&block : String -> )
Iterates over each directory and file underneath the root that matches the FinderRules passed in or all of them if nothing was passed in.
-
#files : Array(String)
gives you all the files that exist recursively as Array(String)
-
#files(&block : String -> )
allows you to iterate over the files with a block
-
#find(fragment : String) : Array(String)
Returns an array of paths recursively under root that include fragment in the path
-
#find(fragment : Regex) : Array(String)
Returns an array of paths recursively under root that match your regex fragment
- #passes_rules(f)
- #root : String
-
#select(&block : String -> Bool)
Returns an array of paths recursively under root that are truthy for the block
-
#walk(d = @root, &block : String, Array(String), Array(String) -> )
Port of Python's os.walk.
Constructor Detail
Instance Method Detail
Iterates over each directory and file underneath the root that matches the FinderRules passed in or all of them if nothing was passed in.
Returns an array of paths recursively under root that include fragment in the path
Returns an array of paths recursively under root that match your regex fragment
Returns an array of paths recursively under root that are truthy for the block
Port of Python's os.walk. It recursively iterates through the root directory and at each level will give yield you the current directory, array of directories in the current directory, and the same thing for files.