From e6e1428b3a96880d2dd4d81d5125214d2171f85e Mon Sep 17 00:00:00 2001 From: Allison Theobold Date: Sat, 16 May 2026 12:12:17 -0700 Subject: [PATCH] add extra message for candygram --- R/give_candygrams.R | 16 +--------------- README.md | 6 +++--- 2 files changed, 4 insertions(+), 18 deletions(-) diff --git a/R/give_candygrams.R b/R/give_candygrams.R index 8d71397..c152890 100644 --- a/R/give_candygrams.R +++ b/R/give_candygrams.R @@ -12,28 +12,20 @@ #' @export give_candygrams <- function(person, number, extra_message = NULL) { - stopifnot(number > 0) if (str_detect(person, "Gretchen")) { - return(cat("None for Gretchen Weiners.")) - } if (is.null(extra_message)) { - extra_message <- add_commentary(person, number) - } number <- str_to_title(as.english(number)) - glue::glue("{number} for {person}.") - - - + glue::glue("{number} for {person}. {extra_message}") } #' Tacks commentary on to candygram announcement @@ -43,21 +35,15 @@ give_candygrams <- function(person, number, #' #' @return A string (possibly blank) add_commentary <- function(person, number) { - if (stringr::str_detect(person, "Aaron")) { - return("They are from Regina.") - } if (number > 3) { - return(glue::glue("You go, {person}!")) - } return("") - } diff --git a/README.md b/README.md index 876c029..afc7c8a 100644 --- a/README.md +++ b/README.md @@ -92,7 +92,7 @@ You can also give extra commentary to your announcement: ``` r give_candygrams("Taylor Zimmerman", 2, extra_message = "Merry Christmas!") -#> Two for Taylor Zimmerman. +#> Two for Taylor Zimmerman. Merry Christmas! ``` Some special cases trigger automatic extra commentary or special @@ -100,10 +100,10 @@ behavior: ``` r give_candygrams("Glen Coco", 4) -#> Four for Glen Coco. +#> Four for Glen Coco. You go, Glen Coco! ``` ``` r give_candygrams("Gretchen Weiners", 4) -#> [1] "None for Grethen Weiners." +#> None for Gretchen Weiners. ```