'update'
authorBenjamin Auder <benjamin.auder@somewhere>
Sat, 25 Feb 2017 13:40:25 +0000 (14:40 +0100)
committerBenjamin Auder <benjamin.auder@somewhere>
Sat, 25 Feb 2017 13:40:25 +0000 (14:40 +0100)
pkg/R/Data.R

index 4e16805..18c67dd 100644 (file)
 #'
 #' @export
 Data = R6Class("Data",
+       private = list(
+               .data = "list"
+       ),
        public = list(
-               data = "list",
                initialize = function(...)
-               {
-                       "Initialize empty Data object"
-#TODO: continue from here
-                       callSuper(...)
-               },
+                       initialize(self, private, ...)
+               ,
                getSize = function()
-               {
-                       "Number of series in the dataset"
-
-                       length(data)
-               },
+                       getSize()
+               ,
                getStdHorizon = function()
-               {
-                       "'Standard' horizon, from t+1 to midnight"
-
-                       24 - as.POSIXlt( data[[1]]$time[1] )$hour + 1
-               },
+                       getStdHorizon(self, private)
+               ,
                append = function(new_time, new_serie, new_level, new_exo_hat, new_exo)
-               {
-                       "Acquire a new vector of lists (time, serie, level, exo_hat, exo)"
+                       append(self, private, 
 
                        data[[length(data)+1]] <<- list("time"=new_time,"serie"=new_serie,"level"=new_level,
                                "exo_hat"=new_exo_hat,"exo"=new_exo)
@@ -87,3 +79,19 @@ Data = R6Class("Data",
                }
        )
 )
+
+#' Initialize empty Data object
+initialize = function(self, private, ...)
+{
+       invisible(self)
+}
+
+#' Number of series in the dataset
+getSize = function(self, private)
+       length(private$.data)
+
+#' 'Standard' horizon, from t+1 to midnight
+getStdHorizon = function(self, private)
+       24 - as.POSIXlt( private$.data[[1]]$time[1] )$hour + 1
+
+#' Acquire a new vector of lists (time, centered_serie, level, exo, exo_hat)