class Faker::File
def dir(segment_count: 3, root: nil, directory_separator: ::File::Separator)
-
(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
def extension
-
(String)
-
def extension fetch('file.extension') end
def file_name(dir: nil, name: nil, ext: nil, directory_separator: ::File::Separator)
-
(String)
-
Parameters:
-
directory_separator
(String
) -- Specifies the separator between the directory and name elements. -
ext
(String
) -- Specifies the extension used the generated file. -
name
(String
) -- Specifies the filename used for the generated file. -
dir
(String
) -- Specifies the path used for the generated file.
def file_name(dir: nil, name: nil, ext: nil, directory_separator: ::File::Separator) dir ||= dir(segment_count: 1) name ||= Faker::Lorem.word.downcase ext ||= extension [dir, name].join(directory_separator) + ".#{ext}" end
def mime_type(media_type: nil)
-
(String)
-
def mime_type(media_type: nil) media_type ? fetch("file.mime_type.#{media_type}") : sample(sample(translate('faker.file.mime_type').values)) end