class Faker::File

def dir(segment_count: 3, root: nil, directory_separator: ::File::Separator)

Returns:
  • (String) -

Parameters:
  • directory_separator (String) -- Specifies the separator between the segments.
  • root (String) -- Specifies the root of the generated string.
  • segment_count (Integer) -- Specifies the number of nested folders in the generated string.
def dir(segment_count: 3, root: nil, directory_separator: ::File::Separator)
  Array
    .new(segment_count) { Faker::Internet.slug }
    .unshift(root)
    .compact
    .join(directory_separator)
    .squeeze(directory_separator)
end