Learn R Programming

vcr (version 1.6.0)

FileSystem: File system persister

Description

The only built-in cassette persister. Persists cassettes to the file system.

Arguments

Public fields

file_name

(character) the file name, not whole path

write_fxn

(character) fxn to use for writing to disk

content

(character) content to record to a cassette

path

(character) storage directory for cassettes

write2disk

(character) write to disk or make a new FileSystem

Methods


Method new()

Create a new FileSystem object

Usage

FileSystem$new(
  file_name = NULL,
  write_fxn = NULL,
  content = NULL,
  path = NULL,
  write2disk = FALSE
)

Arguments

file_name

(character) the file name, not whole path

write_fxn

(character) fxn to use for writing to disk

content

(character) content to record to a cassette

path

(character) storage directory for cassettes

write2disk

(logical) write to disk or just make a new FileSystem object. Default: FALSE

Returns

A new FileSystem object


Method get_cassette()

Gets the cassette for the given storage key (file name)

Usage

FileSystem$get_cassette(file_name = NULL)

Arguments

file_name

(character) the file name, not whole path

Returns

named list, from yaml::yaml.load_file


Method is_empty()

Checks if a cassette is empty or not

Usage

FileSystem$is_empty()

Returns

logical


Method set_cassette()

Sets the cassette for the given storage key (file name)

Usage

FileSystem$set_cassette(file_name = NULL, content)

Arguments

file_name

(character) the file name, not whole path

content

(character) content to record to a cassette

Returns

no return; writes to disk


Method clone()

The objects of this class are cloneable with this method.

Usage

FileSystem$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.

Details

Private Methods

storage_location()

Get storage location

absolute_path_to_file()

Get absolute path to the storage_location