R/show.token.R

Defines functions print.token print.ws_result reveal

Documented in print.token reveal

#' Print method for token
#'
#' @return NULL
#' @param x an object used to select a method.
#' @param ... further arguments passed to or from other methods
#' @param reveal Should the token be revealed
#' @export
#'
#' @examples
#' x = "asdf"
#' class(x) = "token"
#' print(x)
#' print(x, reveal = TRUE)
#' @method print token
print.token = function(x, reveal = FALSE, ...) {
  if (reveal) {
    print(as.character(x), ...)
  } else {
    cat("<hidden token>")
  }
}

#' @export
print.ws_result = function(x, reveal = FALSE, ...) {
  if (reveal) {
    print(as.list(x), ...)
  } else {
    print(x$response)
  }
}

#' @export
#' @rdname print.token
reveal = function(x, ...) {
  print(x, reveal = TRUE, ...)
}

Try the rscopus package in your browser

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

rscopus documentation built on Sept. 18, 2019, 1:03 a.m.