new_pillar: Construct a custom pillar object

View source: R/ctl_pillar.R

new_pillarR Documentation

Construct a custom pillar object

Description

[Experimental]

new_pillar() is the low-level constructor for pillar objects. It supports arbitrary components. See pillar() for the high-level constructor with default components.

Usage

new_pillar(components, ..., width = NULL, class = NULL, extra = deprecated())

Arguments

components

A named list of components constructed with pillar_component().

...

These dots are for future extensions and must be empty.

width

Default width, optional.

class

Name of subclass.

extra

Deprecated.

Details

Arbitrary components are supported. If your tibble subclass needs more or different components in its pillars, override or extend ctl_new_pillar() and perhaps ctl_new_pillar_list().

Examples

lines <- function(char = "-") {
  stopifnot(nchar(char) == 1)
  structure(char, class = "lines")
}

format.lines <- function(x, width, ...) {
  paste(rep(x, width), collapse = "")
}

new_pillar(list(
  title = pillar_component(new_ornament(c("abc", "de"), align = "right")),
  lines = new_pillar_component(list(lines("=")), width = 1)
))

pillar documentation built on March 31, 2023, 10:19 p.m.