@@ -3,7 +3,7 @@ format.blob <- function(x, ...) {
33 if (length(x ) == 0 )
44 return (character ())
55
6- ifelse(is.na(x ), " <NA>" , paste0(" blob[" , blob_size(x , ... ) , " ]" ))
6+ ifelse(is.na(x ), " <NA>" , paste0(" blob[" , blob_size(x , ... ), " ]" ))
77}
88
99# ' @export
@@ -16,25 +16,25 @@ print.blob <- function(x, ...) {
1616}
1717
1818# ' @export
19- # ' @importFrom tibble type_sum
19+ # ' @importFrom pillar type_sum
2020type_sum.blob <- function (x ) {
2121 " blob"
2222}
2323
2424# ' @export
25- # ' @importFrom tibble obj_sum
25+ # ' @importFrom pillar obj_sum
2626obj_sum.blob <- function (x ) {
2727 format(x , trim = FALSE )
2828}
2929
3030# ' @export
31- # ' @importFrom tibble is_vector_s3
31+ # ' @importFrom pillar is_vector_s3
3232is_vector_s3.blob <- function (x ) TRUE
3333
3434blob_size <- function (x , digits = 3 , trim = TRUE , ... ) {
3535 x <- vapply(x , length , numeric (1 ))
3636
37- units <- c(" kb " , " Mb " , " Gb " , " Tb " )
37+ units <- c(" kB " , " MB " , " GB " , " TB " )
3838 power <- min(floor(log(abs(x ), 1000 )), length(units ))
3939 if (power < 1 ) {
4040 unit <- " B"
@@ -47,3 +47,15 @@ blob_size <- function(x, digits = 3, trim = TRUE, ...) {
4747 x2 <- format(x1 , big.mark = " ," , scientific = FALSE , trim = trim )
4848 paste0(x2 , " " , unit )
4949}
50+
51+ # ' @importFrom pillar pillar_shaft
52+ # ' @export
53+ pillar_shaft.blob <- function (x , ... ) {
54+ out <- ifelse(
55+ is.na(x ),
56+ NA_character_ ,
57+ paste0(pillar :: style_subtle(" [" ), blob_size(x , ... ), pillar :: style_subtle(" ]" ))
58+ )
59+
60+ pillar :: new_pillar_shaft_simple(out , align = " right" )
61+ }
0 commit comments