Skip to contents

file methods

Super class

charlatan::BaseProvider -> FileProvider

Public fields

locale

(character) the locale

Methods

Inherited methods


Method allowed_locales()

fetch the allowed locales for this provider

Usage

FileProvider$allowed_locales()


Method new()

Create a new FileProvider object

Usage

FileProvider$new(locale = NULL)

Arguments

locale

(character) the locale to use. See $allowed_locales() for locales supported (default: en_US)

Returns

A new FileProvider object


Method mime_type()

a random mime type

Usage

FileProvider$mime_type(category = NULL)

Arguments

category

(character) a mime type category of mime types, one of application, audio, image, message, model, multipart, text or video. default: NULL


Method file_name()

a random file name

Usage

FileProvider$file_name(category = NULL, extension = NULL)

Arguments

category

(character) a category of file extension type, one of audio, image, office, text or video. default: NULL. If this is given, extension is ignored

extension

(character) a file extension. if this is given, category is ignored.


Method file_extension()

a random file extension

Usage

FileProvider$file_extension(category = NULL)

Arguments

category

(character) a category of file extension type, one of audio, image, office, text or video. default: NULL


Method file_path()

a random file path

Usage

FileProvider$file_path(depth = 1, category = NULL, extension = NULL)

Arguments

depth

(character) depth of the file (depth >= 0). default: 1

category

(character) a category of file extension type, one of audio, image, office, text or video. default: NULL. If this is given, extension is ignored

extension

(character) a file extension. if this is given, category is ignored.


Method clone()

The objects of this class are cloneable with this method.

Usage

FileProvider$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.

Examples

(x <- FileProvider$new())
#> <FileProvider>
#>   Inherits from: <BaseProvider>
#>   Public:
#>     allowed_locales: function () 
#>     bothify: function (text = "## ??") 
#>     check_locale: function (x) 
#>     clone: function (deep = FALSE) 
#>     file_extension: function (category = NULL) 
#>     file_name: function (category = NULL, extension = NULL) 
#>     file_path: function (depth = 1, category = NULL, extension = NULL) 
#>     initialize: function (locale = NULL) 
#>     lexify: function (text = "????") 
#>     locale: en_US
#>     mime_type: function (category = NULL) 
#>     numerify: function (text = "###") 
#>     random_digit: function () 
#>     random_digit_not_zero: function () 
#>     random_digit_not_zero_or_empty: function () 
#>     random_digit_or_empty: function () 
#>     random_element: function (x) 
#>     random_element_prob: function (x) 
#>     random_int: function (min = 0, max = 9999, size = 1) 
#>     random_letter: function () 
#>     randomize_nb_elements: function (number = 10, le = FALSE, ge = FALSE, min = NULL, max = NULL) 
#>   Private:
#>     application_mime_types: application/atom+xml application/ecmascript application/ ...
#>     audio_file_extensions: flac mp3 wav
#>     audio_mime_types: audio/basic audio/L24 audio/mp4 audio/mpeg audio/ogg aud ...
#>     file_extensions: list
#>     image_file_extensions: bmp gif jpeg jpg png tiff
#>     image_mime_types: image/gif image/jpeg image/pjpeg image/png image/svg+xml ...
#>     locales: en_US
#>     message_mime_types: message/http message/imdn+xml message/partial message/rfc822
#>     mime_types: list
#>     model_mime_types: model/example model/iges model/mesh model/vrml model/x3d ...
#>     multipart_mime_types: multipart/mixed multipart/alternative multipart/related  ...
#>     office_file_extensions: doc docx xls xlsx ppt pptx odt ods odp pages numbers key pdf
#>     text_file_extensions: css csv html js json txt
#>     text_mime_types: text/cmd text/css text/csv text/html text/javascript tex ...
#>     video_file_extensions: mp4 avi mov webm
#>     video_mime_types: video/mpeg video/mp4 video/ogg video/quicktime video/web ...
x$locale
#> [1] "en_US"
x$mime_type()
#> [1] "video/quicktime"
x$file_extension()
#> [1] "avi"
x$file_name()
#> [1] "free.csv"
x$file_path()
#> [1] "/medical/school.pptx"
x$file_path(depth = 2)
#> [1] "/nature/officer/it.avi"
x$file_path(depth = 3)
#> [1] "/race/control/main/answer.html"
x$file_path(depth = 6)
#> [1] "/leader/capital/hundred/most/not/visit/test.json"