-
- 1 |
- |
-
- #' @title `Reporter`
- |
-
-
- 2 |
- |
-
- #' @description `r lifecycle::badge("experimental")`
- |
-
-
- 3 |
- |
-
- #' R6 class that stores and manages report cards.
- |
-
-
- 4 |
- |
-
- #' @export
- |
-
-
- 5 |
- |
-
- #'
- |
-
-
- 6 |
- |
-
- Reporter <- R6::R6Class( # nolint: object_name_linter.
- |
-
-
- 7 |
- |
-
- classname = "Reporter",
- |
-
-
- 8 |
- |
-
- public = list(
- |
-
-
- 9 |
- |
-
- #' @description Returns a `Reporter` object.
- |
-
-
- 10 |
- |
-
- #'
- |
-
-
- 11 |
- |
-
- #' @return a `Reporter` object
- |
-
-
- 12 |
- |
-
- #' @examples
- |
-
-
- 13 |
- |
-
- #' reporter <- teal.reporter::Reporter$new()
- |
-
-
- 14 |
- |
-
- #'
- |
-
-
- 15 |
- |
-
- initialize = function() {
- |
-
-
- 16 |
- 44x |
-
- private$cards <- list()
- |
-
-
- 17 |
- 44x |
-
- private$reactive_add_card <- shiny::reactiveVal(0)
- |
-
-
- 18 |
- 44x |
-
- invisible(self)
- |
-
-
- 19 |
- |
-
- },
- |
-
-
- 20 |
- |
-
- #' @description Appends a table to this `Reporter`.
- |
-
-
- 21 |
- |
-
- #'
- |
-
-
- 22 |
- |
-
- #' @param cards [`ReportCard`] or a list of such objects
- |
-
-
- 23 |
- |
-
- #' @return invisibly self
- |
-
-
- 24 |
- |
-
- #' @examples
- |
-
-
- 25 |
- |
-
- #' card1 <- teal.reporter::ReportCard$new()
- |
-
-
- 26 |
- |
-
- #'
- |
-
-
- 27 |
- |
-
- #' card1$append_text("Header 2 text", "header2")
- |
-
-
- 28 |
- |
-
- #' card1$append_text("A paragraph of default text", "header2")
- |
-
-
- 29 |
- |
-
- #' card1$append_plot(
- |
-
-
- 30 |
- |
-
- #' ggplot2::ggplot(iris, ggplot2::aes(x = Petal.Length)) + ggplot2::geom_histogram()
- |
-
-
- 31 |
- |
-
- #' )
- |
-
-
- 32 |
- |
-
- #'
- |
-
-
- 33 |
- |
-
- #' card2 <- teal.reporter::ReportCard$new()
- |
-
-
- 34 |
- |
-
- #'
- |
-
-
- 35 |
- |
-
- #' card2$append_text("Header 2 text", "header2")
- |
-
-
- 36 |
- |
-
- #' card2$append_text("A paragraph of default text", "header2")
- |
-
-
- 37 |
- |
-
- #' lyt <- rtables::analyze(rtables::split_rows_by(rtables::basic_table(), "Day"), "Ozone", afun = mean)
- |
-
-
- 38 |
- |
-
- #' table_res2 <- rtables::build_table(lyt, airquality)
- |
-
-
- 39 |
- |
-
- #' card2$append_table(table_res2)
- |
-
-
- 40 |
- |
-
- #' card2$append_table(iris)
- |
-
-
- 41 |
- |
-
- #'
- |
-
-
- 42 |
- |
-
- #' reporter <- teal.reporter::Reporter$new()
- |
-
-
- 43 |
- |
-
- #' reporter$append_cards(list(card1, card2))
- |
-
-
- 44 |
- |
-
- #'
- |
-
-
- 45 |
- |
-
- append_cards = function(cards) {
- |
-
-
- 46 |
- 41x |
-
- checkmate::assert_list(cards, "ReportCard")
- |
-
-
- 47 |
- 41x |
-
- private$cards <- append(private$cards, cards)
- |
-
-
- 48 |
- 41x |
-
- private$reactive_add_card(length(private$cards))
- |
-
-
- 49 |
- 41x |
-
- invisible(self)
- |
-
-
- 50 |
- |
-
- },
- |
-
-
- 51 |
- |
-
- #' @description Returns cards of this `Reporter`.
- |
-
-
- 52 |
- |
-
- #'
- |
-
-
- 53 |
- |
-
- #' @return `list()` list of [`ReportCard`]
- |
-
-
- 54 |
- |
-
- #' @examples
- |
-
-
- 55 |
- |
-
- #' card1 <- teal.reporter::ReportCard$new()
- |
-
-
- 56 |
- |
-
- #'
- |
-
-
- 57 |
- |
-
- #' card1$append_text("Header 2 text", "header2")
- |
-
-
- 58 |
- |
-
- #' card1$append_text("A paragraph of default text", "header2")
- |
-
-
- 59 |
- |
-
- #' card1$append_plot(
- |
-
-
- 60 |
- |
-
- #' ggplot2::ggplot(iris, ggplot2::aes(x = Petal.Length)) + ggplot2::geom_histogram()
- |
-
-
- 61 |
- |
-
- #' )
- |
-
-
- 62 |
- |
-
- #'
- |
-
-
- 63 |
- |
-
- #' card2 <- teal.reporter::ReportCard$new()
- |
-
-
- 64 |
- |
-
- #'
- |
-
-
- 65 |
- |
-
- #' card2$append_text("Header 2 text", "header2")
- |
-
-
- 66 |
- |
-
- #' card2$append_text("A paragraph of default text", "header2")
- |
-
-
- 67 |
- |
-
- #' lyt <- rtables::analyze(rtables::split_rows_by(rtables::basic_table(), "Day"), "Ozone", afun = mean)
- |
-
-
- 68 |
- |
-
- #' table_res2 <- rtables::build_table(lyt, airquality)
- |
-
-
- 69 |
- |
-
- #' card2$append_table(table_res2)
- |
-
-
- 70 |
- |
-
- #' card2$append_table(iris)
- |
-
-
- 71 |
- |
-
- #'
- |
-
-
- 72 |
- |
-
- #' reporter <- teal.reporter::Reporter$new()
- |
-
-
- 73 |
- |
-
- #' reporter$append_cards(list(card1, card2))
- |
-
-
- 74 |
- |
-
- #' reporter$get_cards()
- |
-
-
- 75 |
- |
-
- get_cards = function() {
- |
-
-
- 76 |
- 72x |
-
- private$cards
- |
-
-
- 77 |
- |
-
- },
- |
-
-
- 78 |
- |
-
- #' @description Returns blocks of all [`ReportCard`] of this `Reporter`.
- |
-
-
- 79 |
- |
-
- #'
- |
-
-
- 80 |
- |
-
- #' @param sep the element inserted between each content element in this `Reporter`.
- |
-
-
- 81 |
- |
-
- #' Pass `NULL` to return content without any additional elements. Default: `NewpageBlock$new()`
- |
-
-
- 82 |
- |
-
- #' @return `list()` list of `TableBlock`, `TextBlock`, `PictureBlock` and `NewpageBlock`
- |
-
-
- 83 |
- |
-
- #' @examples
- |
-
-
- 84 |
- |
-
- #' card1 <- teal.reporter::ReportCard$new()
- |
-
-
- 85 |
- |
-
- #'
- |
-
-
- 86 |
- |
-
- #' card1$append_text("Header 2 text", "header2")
- |
-
-
- 87 |
- |
-
- #' card1$append_text("A paragraph of default text", "header2")
- |
-
-
- 88 |
- |
-
- #' card1$append_plot(
- |
-
-
- 89 |
- |
-
- #' ggplot2::ggplot(iris, ggplot2::aes(x = Petal.Length)) + ggplot2::geom_histogram()
- |
-
-
- 90 |
- |
-
- #' )
- |
-
-
- 91 |
- |
-
- #'
- |
-
-
- 92 |
- |
-
- #' card2 <- teal.reporter::ReportCard$new()
- |
-
-
- 93 |
- |
-
- #'
- |
-
-
- 94 |
- |
-
- #' card2$append_text("Header 2 text", "header2")
- |
-
-
- 95 |
- |
-
- #' card2$append_text("A paragraph of default text", "header2")
- |
-
-
- 96 |
- |
-
- #' lyt <- rtables::analyze(rtables::split_rows_by(rtables::basic_table(), "Day"), "Ozone", afun = mean)
- |
-
-
- 97 |
- |
-
- #' table_res2 <- rtables::build_table(lyt, airquality)
- |
-
-
- 98 |
- |
-
- #' card2$append_table(table_res2)
- |
-
-
- 99 |
- |
-
- #' card2$append_table(iris)
- |
-
-
- 100 |
- |
-
- #'
- |
-
-
- 101 |
- |
-
- #' reporter <- teal.reporter::Reporter$new()
- |
-
-
- 102 |
- |
-
- #' reporter$append_cards(list(card1, card2))
- |
-
-
- 103 |
- |
-
- #' reporter$get_blocks()
- |
-
-
- 104 |
- |
-
- #'
- |
-
-
- 105 |
- |
-
- get_blocks = function(sep = NewpageBlock$new()) {
- |
-
-
- 106 |
- 36x |
-
- blocks <- list()
- |
-
-
- 107 |
- 36x |
-
- if (length(private$cards) > 0) {
- |
-
-
- 108 |
- 33x |
-
- for (card_idx in head(seq_along(private$cards), -1)) {
- |
-
-
- 109 |
- 14x |
-
- blocks <- append(blocks, append(private$cards[[card_idx]]$get_content(), sep))
- |
-
-
- 110 |
- |
-
- }
- |
-
-
- 111 |
- 33x |
-
- blocks <- append(blocks, private$cards[[length(private$cards)]]$get_content())
- |
-
-
- 112 |
- |
-
- }
- |
-
-
- 113 |
- 36x |
-
- blocks
- |
-
-
- 114 |
- |
-
- },
- |
-
-
- 115 |
- |
-
- #' @description Removes all [`ReportCard`] objects added to this `Reporter`.
- |
-
-
- 116 |
- |
-
- #' Additionally all metadata are removed.
- |
-
-
- 117 |
- |
-
- #'
- |
-
-
- 118 |
- |
-
- #' @return invisibly self
- |
-
-
- 119 |
- |
-
- #'
- |
-
-
- 120 |
- |
-
- reset = function() {
- |
-
-
- 121 |
- 27x |
-
- private$cards <- list()
- |
-
-
- 122 |
- 27x |
-
- private$metadata <- list()
- |
-
-
- 123 |
- 27x |
-
- private$reactive_add_card(0)
- |
-
-
- 124 |
- 27x |
-
- invisible(self)
- |
-
-
- 125 |
- |
-
- },
- |
-
-
- 126 |
- |
-
- #' @description remove a specific Card in the Reporter
- |
-
-
- 127 |
- |
-
- #'
- |
-
-
- 128 |
- |
-
- #' @param ids `integer` the indexes of cards
- |
-
-
- 129 |
- |
-
- #' @return invisibly self
- |
-
-
- 130 |
- |
-
- remove_cards = function(ids = NULL) {
- |
-
-
- 131 |
- 1x |
-
- checkmate::assert(
- |
-
-
- 132 |
- 1x |
-
- checkmate::check_null(ids),
- |
-
-
- 133 |
- 1x |
-
- checkmate::check_integer(ids, min.len = 1, max.len = length(private$cards))
- |
-
-
- 134 |
- |
-
- )
- |
-
-
- 135 |
- 1x |
-
- if (!is.null(ids)) {
- |
-
-
- 136 |
- 1x |
-
- private$cards <- private$cards[-ids]
- |
-
-
- 137 |
- |
-
- }
- |
-
-
- 138 |
- 1x |
-
- private$reactive_add_card(length(private$cards))
- |
-
-
- 139 |
- 1x |
-
- invisible(self)
- |
-
-
- 140 |
- |
-
- },
- |
-
-
- 141 |
- |
-
- #' @description swap two cards in the Reporter
- |
-
-
- 142 |
- |
-
- #'
- |
-
-
- 143 |
- |
-
- #' @param start `integer` the index of the first card
- |
-
-
- 144 |
- |
-
- #' @param end `integer` the index of the second card
- |
-
-
- 145 |
- |
-
- #' @return invisibly self
- |
-
-
- 146 |
- |
-
- swap_cards = function(start, end) {
- |
-
-
- 147 |
- 6x |
-
- checkmate::assert(
- |
-
-
- 148 |
- 6x |
-
- checkmate::check_integer(start,
- |
-
-
- 149 |
- 6x |
-
- min.len = 1, max.len = 1, lower = 1, upper = length(private$cards)
- |
-
-
- 150 |
- |
-
- ),
- |
-
-
- 151 |
- 6x |
-
- checkmate::check_integer(end,
- |
-
-
- 152 |
- 6x |
-
- min.len = 1, max.len = 1, lower = 1, upper = length(private$cards)
- |
-
-
- 153 |
- |
-
- ),
- |
-
-
- 154 |
- 6x |
-
- combine = "and"
- |
-
-
- 155 |
- |
-
- )
- |
-
-
- 156 |
- 6x |
-
- start_val <- private$cards[[start]]$clone()
- |
-
-
- 157 |
- 6x |
-
- end_val <- private$cards[[end]]$clone()
- |
-
-
- 158 |
- 6x |
-
- private$cards[[start]] <- end_val
- |
-
-
- 159 |
- 6x |
-
- private$cards[[end]] <- start_val
- |
-
-
- 160 |
- 6x |
-
- invisible(self)
- |
-
-
- 161 |
- |
-
- },
- |
-
-
- 162 |
- |
-
- #' @description get a value for the reactive value for the add card
- |
-
-
- 163 |
- |
-
- #'
- |
-
-
- 164 |
- |
-
- #' @return `reactive_add_card` field value
- |
-
-
- 165 |
- |
-
- #' @note The function has to be used in the shiny reactive context.
- |
-
-
- 166 |
- |
-
- #' @examples
- |
-
-
- 167 |
- |
-
- #' shiny::isolate(Reporter$new()$get_reactive_add_card())
- |
-
-
- 168 |
- |
-
- get_reactive_add_card = function() {
- |
-
-
- 169 |
- 23x |
-
- private$reactive_add_card()
- |
-
-
- 170 |
- |
-
- },
- |
-
-
- 171 |
- |
-
- #' @description get metadata of this `Reporter`.
- |
-
-
- 172 |
- |
-
- #'
- |
-
-
- 173 |
- |
-
- #' @return metadata
- |
-
-
- 174 |
- |
-
- #' @examples
- |
-
-
- 175 |
- |
-
- #' reporter <- Reporter$new()$append_metadata(list(sth = "sth"))
- |
-
-
- 176 |
- |
-
- #' reporter$get_metadata()
- |
-
-
- 177 |
- |
-
- #'
- |
-
-
- 178 |
- |
-
- get_metadata = function() {
- |
-
-
- 179 |
- 17x |
-
- private$metadata
- |
-
-
- 180 |
- |
-
- },
- |
-
-
- 181 |
- |
-
- #' @description Appends metadata to this `Reporter`.
- |
-
-
- 182 |
- |
-
- #'
- |
-
-
- 183 |
- |
-
- #' @param meta (`list`) of metadata.
- |
-
-
- 184 |
- |
-
- #' @return invisibly self
- |
-
-
- 185 |
- |
-
- #' @examples
- |
-
-
- 186 |
- |
-
- #' reporter <- Reporter$new()$append_metadata(list(sth = "sth"))
- |
-
-
- 187 |
- |
-
- #' reporter$get_metadata()
- |
-
-
- 188 |
- |
-
- #'
- |
-
-
- 189 |
- |
-
- append_metadata = function(meta) {
- |
-
-
- 190 |
- 25x |
-
- checkmate::assert_list(meta, names = "unique")
- |
-
-
- 191 |
- 22x |
-
- checkmate::assert_true(length(meta) == 0 || all(!names(meta) %in% names(private$metadata)))
- |
-
-
- 192 |
- 21x |
-
- private$metadata <- append(private$metadata, meta)
- |
-
-
- 193 |
- 21x |
-
- invisible(self)
- |
-
-
- 194 |
- |
-
- },
- |
-
-
- 195 |
- |
-
- #' @description Create/Recreate a Reporter from another Reporter
- |
-
-
- 196 |
- |
-
- #' @param reporter `Reporter` instance.
- |
-
-
- 197 |
- |
-
- #' @return invisibly self
- |
-
-
- 198 |
- |
-
- #' @examples
- |
-
-
- 199 |
- |
-
- #' reporter <- Reporter$new()
- |
-
-
- 200 |
- |
-
- #' reporter$from_reporter(reporter)
- |
-
-
- 201 |
- |
-
- from_reporter = function(reporter) {
- |
-
-
- 202 |
- 8x |
-
- checkmate::assert_class(reporter, "Reporter")
- |
-
-
- 203 |
- 8x |
-
- self$reset()
- |
-
-
- 204 |
- 8x |
-
- self$append_cards(reporter$get_cards())
- |
-
-
- 205 |
- 8x |
-
- self$append_metadata(reporter$get_metadata())
- |
-
-
- 206 |
- 8x |
-
- invisible(self)
- |
-
-
- 207 |
- |
-
- },
- |
-
-
- 208 |
- |
-
- #' @description Convert a Reporter to a list and transfer files
- |
-
-
- 209 |
- |
-
- #' @param output_dir `character(1)` a path to the directory where files will be copied.
- |
-
-
- 210 |
- |
-
- #' @return `named list` `Reporter` representation
- |
-
-
- 211 |
- |
-
- #' @examples
- |
-
-
- 212 |
- |
-
- #' reporter <- Reporter$new()
- |
-
-
- 213 |
- |
-
- #' tmp_dir <- file.path(tempdir(), "testdir")
- |
-
-
- 214 |
- |
-
- #' dir.create(tmp_dir)
- |
-
-
- 215 |
- |
-
- #' reporter$to_list(tmp_dir)
- |
-
-
- 216 |
- |
-
- to_list = function(output_dir) {
- |
-
-
- 217 |
- 8x |
-
- checkmate::assert_directory_exists(output_dir)
- |
-
-
- 218 |
- 6x |
-
- rlist <- list(version = "1", cards = list())
- |
-
-
- 219 |
- 6x |
-
- rlist[["metadata"]] <- self$get_metadata()
- |
-
-
- 220 |
- 6x |
-
- for (card in self$get_cards()) {
- |
-
-
- 221 |
- |
-
- # we want to have list names being a class names to indicate the class for $from_list
- |
-
-
- 222 |
- 6x |
-
- card_class <- class(card)[1]
- |
-
-
- 223 |
- 6x |
-
- u_card <- list()
- |
-
-
- 224 |
- 6x |
-
- u_card[[card_class]] <- card$to_list(output_dir)
- |
-
-
- 225 |
- 6x |
-
- rlist$cards <- c(rlist$cards, u_card)
- |
-
-
- 226 |
- |
-
- }
- |
-
-
- 227 |
- 6x |
-
- rlist
- |
-
-
- 228 |
- |
-
- },
- |
-
-
- 229 |
- |
-
- #' @description Create/Recreate a Reporter from a list and directory with files
- |
-
-
- 230 |
- |
-
- #' @param rlist `named list` `Reporter` representation.
- |
-
-
- 231 |
- |
-
- #' @param output_dir `character(1)` a path to the directory from which files will be copied.
- |
-
-
- 232 |
- |
-
- #' @return invisibly self
- |
-
-
- 233 |
- |
-
- #' @examples
- |
-
-
- 234 |
- |
-
- #' reporter <- Reporter$new()
- |
-
-
- 235 |
- |
-
- #' tmp_dir <- file.path(tempdir(), "testdir")
- |
-
-
- 236 |
- |
-
- #' unlink(tmp_dir, recursive = TRUE)
- |
-
-
- 237 |
- |
-
- #' dir.create(tmp_dir)
- |
-
-
- 238 |
- |
-
- #' reporter$from_list(reporter$to_list(tmp_dir), tmp_dir)
- |
-
-
- 239 |
- |
-
- from_list = function(rlist, output_dir) {
- |
-
-
- 240 |
- 10x |
-
- checkmate::assert_list(rlist)
- |
-
-
- 241 |
- 10x |
-
- checkmate::assert_directory_exists(output_dir)
- |
-
-
- 242 |
- 10x |
-
- if (rlist$version == "1") {
- |
-
-
- 243 |
- 10x |
-
- new_cards <- list()
- |
-
-
- 244 |
- 10x |
-
- cards_names <- names(rlist$cards)
- |
-
-
- 245 |
- 10x |
-
- cards_names <- gsub("[.][0-9]*$", "", cards_names)
- |
-
-
- 246 |
- 10x |
-
- for (iter_c in seq_along(rlist$cards)) {
- |
-
-
- 247 |
- 16x |
-
- card_class <- cards_names[iter_c]
- |
-
-
- 248 |
- 16x |
-
- card <- rlist$cards[[iter_c]]
- |
-
-
- 249 |
- 16x |
-
- new_card <- eval(str2lang(sprintf("%s$new()", card_class)))
- |
-
-
- 250 |
- 16x |
-
- new_card$from_list(card, output_dir)
- |
-
-
- 251 |
- 16x |
-
- new_cards <- c(new_cards, new_card)
- |
-
-
- 252 |
- |
-
- }
- |
-
-
- 253 |
- |
-
- } else {
- |
-
-
- 254 |
- ! |
-
- stop("The provided version is not supported")
- |
-
-
- 255 |
- |
-
- }
- |
-
-
- 256 |
- 10x |
-
- self$reset()
- |
-
-
- 257 |
- 10x |
-
- self$append_cards(new_cards)
- |
-
-
- 258 |
- 10x |
-
- self$append_metadata(rlist$metadata)
- |
-
-
- 259 |
- 10x |
-
- invisible(self)
- |
-
-
- 260 |
- |
-
- },
- |
-
-
- 261 |
- |
-
- #' @description Create/Recreate a Reporter to a directory with `JSON` file and static files
- |
-
-
- 262 |
- |
-
- #' @param output_dir `character(1)` a path to the directory where files will be copied, `JSON` and statics.
- |
-
-
- 263 |
- |
-
- #' @return invisibly self
- |
-
-
- 264 |
- |
-
- #' @examples
- |
-
-
- 265 |
- |
-
- #' reporter <- Reporter$new()
- |
-
-
- 266 |
- |
-
- #' tmp_dir <- file.path(tempdir(), "jsondir")
- |
-
-
- 267 |
- |
-
- #' dir.create(tmp_dir)
- |
-
-
- 268 |
- |
-
- #' reporter$to_jsondir(tmp_dir)
- |
-
-
- 269 |
- |
-
- to_jsondir = function(output_dir) {
- |
-
-
- 270 |
- 5x |
-
- checkmate::assert_directory_exists(output_dir)
- |
-
-
- 271 |
- 3x |
-
- json <- self$to_list(output_dir)
- |
-
-
- 272 |
- 3x |
-
- cat(jsonlite::toJSON(json, auto_unbox = TRUE, force = TRUE),
- |
-
-
- 273 |
- 3x |
-
- file = file.path(output_dir, "Report.json")
- |
-
-
- 274 |
- |
-
- )
- |
-
-
- 275 |
- 3x |
-
- output_dir
- |
-
-
- 276 |
- |
-
- },
- |
-
-
- 277 |
- |
-
- #' @description Create/Recreate a Reporter from a directory with `JSON` file and static files
- |
-
-
- 278 |
- |
-
- #' @param output_dir `character(1)` a path to the directory with files, `JSON` and statics.
- |
-
-
- 279 |
- |
-
- #' @return invisibly self
- |
-
-
- 280 |
- |
-
- #' @examples
- |
-
-
- 281 |
- |
-
- #' reporter <- Reporter$new()
- |
-
-
- 282 |
- |
-
- #' tmp_dir <- file.path(tempdir(), "jsondir")
- |
-
-
- 283 |
- |
-
- #' dir.create(tmp_dir)
- |
-
-
- 284 |
- |
-
- #' unlink(list.files(tmp_dir, recursive = TRUE))
- |
-
-
- 285 |
- |
-
- #' reporter$to_jsondir(tmp_dir)
- |
-
-
- 286 |
- |
-
- #' reporter$from_jsondir(tmp_dir)
- |
-
-
- 287 |
- |
-
- from_jsondir = function(output_dir) {
- |
-
-
- 288 |
- 8x |
-
- checkmate::assert_directory_exists(output_dir)
- |
-
-
- 289 |
- 8x |
-
- checkmate::assert_true(length(list.files(output_dir)) > 0)
- |
-
-
- 290 |
- 8x |
-
- dir_files <- list.files(output_dir)
- |
-
-
- 291 |
- 8x |
-
- which_json <- grep("json$", dir_files)
- |
-
-
- 292 |
- 8x |
-
- json <- jsonlite::read_json(file.path(output_dir, dir_files[which_json]))
- |
-
-
- 293 |
- 8x |
-
- self$reset()
- |
-
-
- 294 |
- 8x |
-
- self$from_list(json, output_dir)
- |
-
-
- 295 |
- 8x |
-
- invisible(self)
- |
-
-
- 296 |
- |
-
- }
- |
-
-
- 297 |
- |
-
- ),
- |
-
-
- 298 |
- |
-
- private = list(
- |
-
-
- 299 |
- |
-
- cards = list(),
- |
-
-
- 300 |
- |
-
- metadata = list(),
- |
-
-
- 301 |
- |
-
- reactive_add_card = NULL,
- |
-
-
- 302 |
- |
-
- # @description The copy constructor.
- |
-
-
- 303 |
- |
-
- #
- |
-
-
- 304 |
- |
-
- # @param name the name of the field
- |
-
-
- 305 |
- |
-
- # @param value the value of the field
- |
-
-
- 306 |
- |
-
- # @return the new value of the field
- |
-
-
- 307 |
- |
-
- #
- |
-
-
- 308 |
- |
-
- deep_clone = function(name, value) {
- |
-
-
- 309 |
- 20x |
-
- if (name == "cards") {
- |
-
-
- 310 |
- 1x |
-
- lapply(value, function(card) card$clone(deep = TRUE))
- |
-
-
- 311 |
- |
-
- } else {
- |
-
-
- 312 |
- 19x |
-
- value
- |
-
-
- 313 |
- |
-
- }
- |
-
-
- 314 |
- |
-
- }
- |
-
-
- 315 |
- |
-
- ),
- |
-
-
- 316 |
- |
-
- lock_objects = TRUE,
- |
-
-
- 317 |
- |
-
- lock_class = TRUE
- |
-
-
- 318 |
- |
-
- )
- |
-
-
-