Skip to content

Commit

Permalink
Fix get_forecast_type
Browse files Browse the repository at this point in the history
  • Loading branch information
nikosbosse committed Oct 28, 2024
1 parent b370557 commit 4f0fb74
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions R/get-forecast-type.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
#' Character vector of length one with the forecast type.
#' @keywords internal_input_check
get_forecast_type <- function(forecast) {
classname <- class(forecast)[1]
if (grepl("forecast_", classname, fixed = TRUE)) {
type <- gsub("forecast_", "", classname, fixed = TRUE)
return(type)
classname <- class(forecast)
forecast_class <- classname[grepl("forecast_", classname, fixed = TRUE)]
if (length(forecast_class) == 1) {
return(gsub("forecast_", "", forecast_class, fixed = TRUE))
} else {
cli_abort(
"Input is not a valid forecast object
(it's first class should begin with `forecast_`)."
(There should be a single class beginning with `forecast_`)."
)
}
}
Expand Down

0 comments on commit 4f0fb74

Please sign in to comment.