#' cached
#'
#' subclass for working with cached objects: `path`, `dir`, `file`, `name`,
#' `ext`, etc.
#'
#' @param x object to subclass
#'
#' @details
#'
#' These are essentially used for providing special methods for cache objects vs
#' their **fs** counterparts.
#'
#' The biggest difference is *cached* ext vs a fs extension
#'
#' @examples
#'
#' x <- path('cache') %>% cached()
#' print(x) # A cache path(s) at:
#'
#'
#' @export
cached <- function(x, ...) UseMethod('cached')
#' @rdname cached
#' @export
cached.default <- function(x,...)
add_subclass( as.character(x), 'cached')
#' @rdname cached
#' @export
print.cached <- function(x, ...) {
cat('A cached', class(x)[[2]] %>% squote(), ': ' )
x %>%
unclass() %>%
crayon::red() %>%
# squote() %>%
collapse_comma() %>%
cat()
invisible(x)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.