From fbf0035805190740b27d4b326b41443725add00c Mon Sep 17 00:00:00 2001 From: "arsenij.ustjanzew" <arsenij.ustjanzew@mpi-bn.mpg.de> Date: Tue, 18 Feb 2020 11:08:08 +0100 Subject: [PATCH] Easy access getter and setter methods for title, author, datadir and theme --- NAMESPACE | 9 ++++++ R/AllGenerics.R | 26 ++++++++++++++++ R/get_set.R | 64 ++++++++++++++++++++++++++++++++++++++++ man/i2dashboard-class.Rd | 24 +++++++++++++++ 4 files changed, 123 insertions(+) diff --git a/NAMESPACE b/NAMESPACE index 97d8b5e..1f686df 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -1,15 +1,24 @@ # Generated by roxygen2: do not edit by hand export("%>%") +export("author<-") +export("datadir<-") +export("interactivity<-") +export("theme<-") +export("title<-") export(add_colormap) export(add_component) export(add_page) export(add_to_sidebar) export(assemble) +export(author) +export(datadir) export(embed_var) export(i2dashboard) export(interactivity) export(remove_page) +export(theme) +export(title) exportClasses(i2dashboard) exportMethods(add_colormap) exportMethods(add_component) diff --git a/R/AllGenerics.R b/R/AllGenerics.R index b875979..4888ef2 100644 --- a/R/AllGenerics.R +++ b/R/AllGenerics.R @@ -19,4 +19,30 @@ setGeneric("add_colormap", function(dashboard, ...) standardGeneric("add_colorma #' @export setGeneric("interactivity", function(dashboard) standardGeneric("interactivity")) + +#' @export setGeneric("interactivity<-", function(dashboard, value) standardGeneric("interactivity<-")) + +#' @export +setGeneric("title", function(dashboard) standardGeneric("title")) + +#' @export +setGeneric("title<-", function(dashboard, value) standardGeneric("title<-")) + +#' @export +setGeneric("author", function(dashboard) standardGeneric("author")) + +#' @export +setGeneric("author<-", function(dashboard, value) standardGeneric("author<-")) + +#' @export +setGeneric("theme", function(dashboard) standardGeneric("theme")) + +#' @export +setGeneric("theme<-", function(dashboard, value) standardGeneric("theme<-")) + +#' @export +setGeneric("datadir", function(dashboard) standardGeneric("datadir")) + +#' @export +setGeneric("datadir<-", function(dashboard, value) standardGeneric("datadir<-")) \ No newline at end of file diff --git a/R/get_set.R b/R/get_set.R index 2a4ab7d..b51daf8 100644 --- a/R/get_set.R +++ b/R/get_set.R @@ -13,3 +13,67 @@ setMethod("interactivity<-", "i2dashboard", function(dashboard, value) { dashboard@interactive <- value dashboard }) + +#' Get/set the title of the i2dashboard. +#' +#' @param dashboard A \linkS4class{i2dash::i2dashboard}. +#' @param value The value of the desired property. +#' +#' @name i2dashboard-class +#' @rdname i2dashboard-class +setMethod("title", "i2dashboard", function(dashboard) dashboard@title) + +#' @name i2dashboard-class +#' @rdname i2dashboard-class +setMethod("title<-", "i2dashboard", function(dashboard, value) { + dashboard@title <- value + dashboard +}) + +#' Get/set the author of the i2dashboard. +#' +#' @param dashboard A \linkS4class{i2dash::i2dashboard}. +#' @param value The value of the desired property. +#' +#' @name i2dashboard-class +#' @rdname i2dashboard-class +setMethod("author", "i2dashboard", function(dashboard) dashboard@author) + +#' @name i2dashboard-class +#' @rdname i2dashboard-class +setMethod("author<-", "i2dashboard", function(dashboard, value) { + dashboard@author <- value + dashboard +}) + +#' Get/set the theme of the i2dashboard. +#' +#' @param dashboard A \linkS4class{i2dash::i2dashboard}. +#' @param value The value of the desired property. +#' +#' @name i2dashboard-class +#' @rdname i2dashboard-class +setMethod("theme", "i2dashboard", function(dashboard) dashboard@theme) + +#' @name i2dashboard-class +#' @rdname i2dashboard-class +setMethod("theme<-", "i2dashboard", function(dashboard, value) { + dashboard@theme <- value + dashboard +}) + +#' Get/set the datadir of the i2dashboard. +#' +#' @param dashboard A \linkS4class{i2dash::i2dashboard}. +#' @param value The value of the desired property. +#' +#' @name i2dashboard-class +#' @rdname i2dashboard-class +setMethod("datadir", "i2dashboard", function(dashboard) dashboard@datadir) + +#' @name i2dashboard-class +#' @rdname i2dashboard-class +setMethod("datadir<-", "i2dashboard", function(dashboard, value) { + dashboard@datadir <- value + dashboard +}) diff --git a/man/i2dashboard-class.Rd b/man/i2dashboard-class.Rd index bf860c2..d5a103c 100644 --- a/man/i2dashboard-class.Rd +++ b/man/i2dashboard-class.Rd @@ -7,6 +7,22 @@ \S4method{interactivity}{i2dashboard}(dashboard) \S4method{interactivity}{i2dashboard}(dashboard) <- value + +\S4method{title}{i2dashboard}(dashboard) + +\S4method{title}{i2dashboard}(dashboard) <- value + +\S4method{author}{i2dashboard}(dashboard) + +\S4method{author}{i2dashboard}(dashboard) <- value + +\S4method{theme}{i2dashboard}(dashboard) + +\S4method{theme}{i2dashboard}(dashboard) <- value + +\S4method{datadir}{i2dashboard}(dashboard) + +\S4method{datadir}{i2dashboard}(dashboard) <- value } \arguments{ \item{dashboard}{A \linkS4class{i2dash::i2dashboard}.} @@ -15,4 +31,12 @@ } \description{ Get/set the interactivity of the i2dashboard. + +Get/set the title of the i2dashboard. + +Get/set the author of the i2dashboard. + +Get/set the theme of the i2dashboard. + +Get/set the datadir of the i2dashboard. } -- GitLab