#' @title Create a Disk object
#' @description A Disk object is a handle for performing disk read and write operations.
Disk <- R6Class(
classname = "Disk",
public = list(
initialize = function(dir = tempfile()) {
private$dir <- dir
},
write = function(file_name, object) {
saveRDS(object = object, file = private$name_to_path(file_name))
},
read = function(file_name) {
readRDS(private$name_to_path(file_name))
},
delete = function(file_name) {
file.remove(private$name_to_path(file_name))
},
exists = function(file_name) {
file.exists(private$name_to_path(file_name))
},
list_files = function() {
list.files(private$dir, pattern = "*.rds")
}
),
private = list(
dir = NULL,
name_to_path = function(file_name) {
file.path(private$dir, paste0(file_name, ".rds"))
}
)
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.