Class: Faker::File

Inherits:
Base
  • Object
show all
Defined in:
lib/faker/default/file.rb

Constant Summary

Constants inherited from Base

Base::Letters, Base::Numbers, Base::ULetters

Class Method Summary collapse

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(segment_count = 3, root = nil, directory_separator = '/') ⇒ Object


6
7
8
9
10
11
12
13
# File 'lib/faker/default/file.rb', line 6

def dir(segment_count = 3, root = nil, directory_separator = '/')
  Array
    .new(segment_count) { Faker::Internet.slug }
    .unshift(root)
    .compact
    .join(directory_separator)
    .squeeze(directory_separator)
end

.extensionObject


15
16
17
# File 'lib/faker/default/file.rb', line 15

def extension
  fetch('file.extension')
end

.file_name(dir = nil, name = nil, ext = nil, directory_separator = '/') ⇒ Object


23
24
25
26
27
28
29
# File 'lib/faker/default/file.rb', line 23

def file_name(dir = nil, name = nil, ext = nil, directory_separator = '/')
  dir ||= dir(1)
  name ||= Faker::Lorem.word.downcase
  ext ||= extension

  [dir, name].join(directory_separator) + ".#{ext}"
end

.mime_typeObject


19
20
21
# File 'lib/faker/default/file.rb', line 19

def mime_type
  fetch('file.mime_type')
end