From b5195c48e105d53761757becd27765469b03834d Mon Sep 17 00:00:00 2001 From: aheinri5 <Anna@netzkritzler.de> Date: Tue, 24 Nov 2020 09:30:49 +0100 Subject: [PATCH] [bugfix] Altered the constructor so it works with read_in function --- R/prj_parameters.R | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/R/prj_parameters.R b/R/prj_parameters.R index 004db04..d6e2c7c 100644 --- a/R/prj_parameters.R +++ b/R/prj_parameters.R @@ -6,13 +6,25 @@ #'@description S3 class describing a .prj parameter #'@param name The parameter name #'@param type The parameter type -#'@param values The parameter values +#'@param values Optional: The parameter values +#'@param value Optional: The parameter value #'@export -r2ogs6_parameter <- function(name, type, values) { +r2ogs6_parameter <- function(name, type, values = NULL, value = NULL) { + + if(!is.null(values) && !is.null(value)){ + stop(paste("r2ogs6_parameter: Use either 'values' or 'value' parameter (XOR)"), call. = FALSE) + } #Coerce input - if(assertthat::is.string(values)){ - values <- as.double(unlist(strsplit(values, " "))) + if(!is.null(value)){ + if(assertthat::is.string(value)){ + value <- as.double(value) + } + values <- value + }else{ + if(assertthat::is.string(values)){ + values <- as.double(unlist(strsplit(values, " "))) + } } new_r2ogs6_parameter(name, type, values) -- GitLab