class HashGenerator::PathBuilder

Defined in:

hash_generator/path_builder.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new #

[View source]

Instance Method Detail

def walk(path = @root, &block : String, Array(String), Array(String) -> ) #

Pathbuilder.walk is a recursive method that opens parent directories up to their children (nested files and folders). It appends the names of the folders to the parent directory to give an initial path that contains just the succeeding folders nested within the parent directory. For example, if the file name "config.txt" is nested within the following directory: /home/servers/server200/BepInEx/plugins, the directory path would be "home/servers/server200/BepInEx/plugins". This method does not complete the path up to the filenames within the folder. We would need to pass in a block to it that returns an array of nested directories, then loop through each directory, and then get the entries of that directory and append the file name to the parent paths.

Example:

path_builder = PathBuilder.new
path_builder.walk(/home/servers) { |folder| puts folder }
=> "/home/servers/blah"

[View source]