1
- # ' @title `Archiver`: Base class for data archiving
2
- # ' @docType class
3
- # ' @description
4
- # ' A base `R6` class for implementing data archiving functionality.
5
- # '
1
+ # ' @title `Archiver`
6
2
# ' @keywords internal
7
3
Archiver <- R6 :: R6Class( # nolint: object_name_linter.
8
4
classname = " Archiver" ,
9
5
public = list (
10
- # ' @description Initialize an `Archiver` object.
6
+ # ' @description Returns an `Archiver` object.
11
7
# '
12
- # ' @return Object of class `Archiver`, invisibly.
8
+ # ' @return an `Archiver` object
13
9
# ' @examples
14
10
# ' Archiver <- getFromNamespace("Archiver", "teal.reporter")
15
11
# ' Archiver$new()
@@ -20,14 +16,12 @@ Archiver <- R6::R6Class( # nolint: object_name_linter.
20
16
finalize = function () {
21
17
# destructor
22
18
},
23
- # ' @description Reads data from the `Archiver`.
24
- # ' Pure virtual method that should be implemented by inherited classes.
19
+ # ' @description Pure virtual method for reading an `Archiver`.
25
20
read = function () {
26
21
# returns Reporter instance
27
22
stop(" Pure virtual method." )
28
23
},
29
- # ' @description Writes data to the `Archiver`.
30
- # ' Pure virtual method that should be implemented by inherited classes.
24
+ # ' @description Pure virtual method for writing an `Archiver`.
31
25
write = function () {
32
26
stop(" Pure virtual method." )
33
27
}
@@ -36,20 +30,15 @@ Archiver <- R6::R6Class( # nolint: object_name_linter.
36
30
lock_class = TRUE
37
31
)
38
32
39
- # ' @title `FileArchiver`: A File-based `Archiver`
40
- # ' @docType class
41
- # ' @description
42
- # ' Inherits from `Archiver` to provide file-based archiving functionality.
43
- # ' Manages an output directory for storing archived data.
44
- # '
33
+ # ' @title `RDSArchiver`
45
34
# ' @keywords internal
46
35
FileArchiver <- R6 :: R6Class( # nolint: object_name_linter.
47
36
classname = " FileArchiver" ,
48
37
inherit = Archiver ,
49
38
public = list (
50
- # ' @description Initialize a `FileArchiver` object with a unique output directory .
39
+ # ' @description Returns a `FileArchiver` object.
51
40
# '
52
- # ' @return Object of class `FileArchiver`, invisibly.
41
+ # ' @return a `FileArchiver` object
53
42
# ' @examples
54
43
# ' FileArchiver <- getFromNamespace("FileArchiver", "teal.reporter")
55
44
# ' FileArchiver$new()
@@ -61,11 +50,10 @@ FileArchiver <- R6::R6Class( # nolint: object_name_linter.
61
50
invisible (self )
62
51
},
63
52
# ' @description Finalizes a `FileArchiver` object.
64
- # ' Cleans up by removing the output directory and its contents.
65
53
finalize = function () {
66
54
unlink(private $ output_dir , recursive = TRUE )
67
55
},
68
- # ' @description Get `output_dir` field.
56
+ # ' @description get `output_dir` field
69
57
# '
70
58
# ' @return `character` a `output_dir` field path.
71
59
# ' @examples
@@ -80,34 +68,25 @@ FileArchiver <- R6::R6Class( # nolint: object_name_linter.
80
68
)
81
69
)
82
70
83
- # ' @title `JSONArchiver`: A `JSON`-based `Archiver`
84
- # ' @docType class
85
- # ' @description
86
- # ' Inherits from `FileArchiver` to implement `JSON`-based archiving functionality.
87
- # ' Convert `Reporter` instances to and from `JSON` format.
88
- # '
71
+ # ' @title `JSONArchiver`
89
72
# ' @keywords internal
90
73
JSONArchiver <- R6 :: R6Class( # nolint: object_name_linter.
91
74
classname = " JSONArchiver" ,
92
75
inherit = FileArchiver ,
93
76
public = list (
94
- # ' @description Write a `Reporter` instance in `JSON` file.
95
- # ' Serializes a given `Reporter` instance and saves it in the `Archiver`'s output directory,
96
- # ' to this `JSONArchiver` object.
77
+ # ' @description write a `Reporter` instance in to this `JSONArchiver` object.
97
78
# '
98
- # ' @param reporter ( `Reporter`) instance.
79
+ # ' @param reporter `Reporter` instance.
99
80
# '
100
- # ' @return ` self`.
81
+ # ' @return invisibly self
101
82
# ' @examples
102
- # ' library(ggplot2)
103
- # '
104
83
# ' ReportCard <- getFromNamespace("ReportCard", "teal.reporter")
105
84
# ' card1 <- ReportCard$new()
106
85
# '
107
86
# ' card1$append_text("Header 2 text", "header2")
108
87
# ' card1$append_text("A paragraph of default text", "header2")
109
88
# ' card1$append_plot(
110
- # ' ggplot(iris, aes(x = Petal.Length)) + geom_histogram()
89
+ # ' ggplot2:: ggplot(iris, ggplot2:: aes(x = Petal.Length)) + ggplot2:: geom_histogram()
111
90
# ' )
112
91
# '
113
92
# ' Reporter <- getFromNamespace("Reporter", "teal.reporter")
@@ -124,22 +103,19 @@ JSONArchiver <- R6::R6Class( # nolint: object_name_linter.
124
103
reporter $ to_jsondir(private $ output_dir )
125
104
self
126
105
},
127
- # ' @description Read a `Reporter` instance from a `JSON` file.
128
- # ' Converts a `Reporter` instance from the `JSON` file in the `JSONArchiver`'s output directory.
106
+ # ' @description read a `Reporter` instance from a directory with `JSONArchiver`.
129
107
# '
130
- # ' @param path ( `character(1)`) a path to the directory with all proper files.
108
+ # ' @param path `character(1)` a path to the directory with all proper files.
131
109
# '
132
110
# ' @return `Reporter` instance.
133
111
# ' @examples
134
- # ' library(ggplot2)
135
- # '
136
112
# ' ReportCard <- getFromNamespace("ReportCard", "teal.reporter")
137
113
# ' card1 <- ReportCard$new()
138
114
# '
139
115
# ' card1$append_text("Header 2 text", "header2")
140
116
# ' card1$append_text("A paragraph of default text", "header2")
141
117
# ' card1$append_plot(
142
- # ' ggplot(iris, aes(x = Petal.Length)) + geom_histogram()
118
+ # ' ggplot2:: ggplot(iris, ggplot2:: aes(x = Petal.Length)) + ggplot2:: geom_histogram()
143
119
# ' )
144
120
# '
145
121
# ' Reporter <- getFromNamespace("Reporter", "teal.reporter")
0 commit comments