R/fromhere.R

Defines functions print.from_path .DollarNames.from_fn .DollarNames.from_path `$.from_fn` `$.from_path` new_from_path

new_from_path <- function(path) {
  structure(path, class = "from_path")
}

#' @export
`$.from_path` <- function(x, name) {
  new_from_path(file.path(x, name))
}

#' @export
`$.from_fn` <- function(x, name) {
  x(name)
}

#' @importFrom utils .DollarNames
#' @export
.DollarNames.from_path <- function(x, pattern) {
  list.files(x, pattern = pattern)
}

#' @export
.DollarNames.from_fn <- function(x, pattern) {
  list.files(x(), pattern = pattern)
}

#' @export
print.from_path <- function(x, ...) {
  attributes(x) <- NULL
  NextMethod()
}
#
# from_where_factory <- function(x, root) {
#   structure(
#     function(...) {
#       root <-
#       new_from_path(
#         file.path(root, ...)
#       )
#     },
#     class = "from_where"
#   )
# }

Try the fromhere package in your browser

Any scripts or data that you put into this service are public.

fromhere documentation built on April 3, 2025, 8:49 p.m.