Class: Faker::File
Constant Summary
Constants inherited from Base
Base::LLetters, Base::Letters, Base::NOT_GIVEN, Base::Numbers, Base::ULetters
Class Method Summary collapse
-
.dir(legacy_segment_count = NOT_GIVEN, legacy_root = NOT_GIVEN, legacy_directory_separator = NOT_GIVEN, segment_count: 3, root: nil, directory_separator: ::File::Separator) ⇒ String
Produces a random directory name.
-
.extension ⇒ String
Produces a random file extension.
-
.file_name(legacy_dir = NOT_GIVEN, legacy_name = NOT_GIVEN, legacy_ext = NOT_GIVEN, legacy_directory_separator = NOT_GIVEN, dir: nil, name: nil, ext: nil, directory_separator: ::File::Separator) ⇒ String
Produces a random file name.
-
.mime_type ⇒ String
Produces a random mime type.
Methods inherited from Base
bothify, disable_enforce_available_locales, fetch, fetch_all, flexible, letterify, method_missing, numerify, parse, rand, rand_in_range, regexify, resolve, respond_to_missing?, sample, shuffle, translate, unique, with_locale
Class Method Details
.dir(legacy_segment_count = NOT_GIVEN, legacy_root = NOT_GIVEN, legacy_directory_separator = NOT_GIVEN, segment_count: 3, root: nil, directory_separator: ::File::Separator) ⇒ String
Produces a random directory name.
rubocop:disable Metrics/ParameterLists
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/faker/default/file.rb', line 22 def dir(legacy_segment_count = NOT_GIVEN, legacy_root = NOT_GIVEN, legacy_directory_separator = NOT_GIVEN, segment_count: 3, root: nil, directory_separator: ::File::Separator) # rubocop:enable Metrics/ParameterLists warn_for_deprecated_arguments do |keywords| keywords << :segment_count if legacy_segment_count != NOT_GIVEN keywords << :root if legacy_root != NOT_GIVEN keywords << :directory_separator if legacy_directory_separator != NOT_GIVEN end Array .new(segment_count) { Faker::Internet.slug } .unshift(root) .compact .join(directory_separator) .squeeze(directory_separator) end |
.extension ⇒ String
Produces a random file extension.
47 48 49 |
# File 'lib/faker/default/file.rb', line 47 def extension fetch('file.extension') end |
.file_name(legacy_dir = NOT_GIVEN, legacy_name = NOT_GIVEN, legacy_ext = NOT_GIVEN, legacy_directory_separator = NOT_GIVEN, dir: nil, name: nil, ext: nil, directory_separator: ::File::Separator) ⇒ String
Produces a random file name.
rubocop:disable Metrics/ParameterLists
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/faker/default/file.rb', line 81 def file_name(legacy_dir = NOT_GIVEN, legacy_name = NOT_GIVEN, legacy_ext = NOT_GIVEN, legacy_directory_separator = NOT_GIVEN, dir: nil, name: nil, ext: nil, directory_separator: ::File::Separator) # rubocop:enable Metrics/ParameterLists warn_for_deprecated_arguments do |keywords| keywords << :dir if legacy_dir != NOT_GIVEN keywords << :name if legacy_name != NOT_GIVEN keywords << :ext if legacy_ext != NOT_GIVEN keywords << :directory_separator if legacy_directory_separator != NOT_GIVEN end dir ||= dir(segment_count: 1) name ||= Faker::Lorem.word.downcase ext ||= extension [dir, name].join(directory_separator) + ".#{ext}" end |
.mime_type ⇒ String
Produces a random mime type.
60 61 62 |
# File 'lib/faker/default/file.rb', line 60 def mime_type fetch('file.mime_type') end |