Class: Faker::File

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

Constant Summary

Constants inherited from Base

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

Class Method Summary collapse

Methods inherited from Base

bothify, fetch, fetch_all, flexible, letterify, method_missing, numerify, parse, rand, rand_in_range, regexify, sample, shuffle, translate, unique, with_locale

Class Method Details

.extensionObject


5
6
7
# File 'lib/faker/file.rb', line 5

def extension
  fetch('file.extension')
end

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


13
14
15
16
17
18
19
20
# File 'lib/faker/file.rb', line 13

def file_name(dir = nil, name = nil, ext = nil, directory_separator = '/')

  dir = Faker::Internet::slug unless dir
  name = Faker::Lorem::word.downcase unless name
  ext ||= extension

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

.mime_typeObject


9
10
11
# File 'lib/faker/file.rb', line 9

def mime_type
  fetch('file.mime_type')
end