-
Notifications
You must be signed in to change notification settings - Fork 4
/
readable.array.R
53 lines (42 loc) · 1.01 KB
/
readable.array.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#' ReadableArray class
#' @description Readable Array class
#' @docType class
#' @importFrom R6 R6Class
#' @export
#' @include constraints.R
#' @include tableschemaerror.R
#' @include profile.R
#' @keywords data
#' @return Object of \code{\link{R6Class}} .
#' @format \code{\link{R6Class}} object.
#'
ReadableArray <- R6Class(
"ReadableArray",
inherit = Readable,
public = list(
initialize = function(options = list()) {
private$array_ <- options$source
},
iterable = function(){
return(iterators::iter(function(){
if (private$index_ <= length(private$array_)) {
value <- private$array_[[private$index_]]
private$index_ <- private$index_ + 1
return(value)
}
else {
stop('StopIteration')
}
}))
}
),
private = list(
index_ = 1,
array_ = list(),
read_ = function(size) {
return(private$array_)
},
destroy_ = function() {
}
)
)