From ed9484985c23276130326bb84b55af723f5a5c4a Mon Sep 17 00:00:00 2001 From: brendad8 <72055001+brendad8@users.noreply.github.com> Date: Mon, 13 May 2024 10:48:29 -0700 Subject: [PATCH] modify give_candygrams function --- R/give_candygrams.R | 12 ++++++++---- README.Rmd | 5 ++++- README.md | 13 +++++++++---- 3 files changed, 21 insertions(+), 9 deletions(-) diff --git a/R/give_candygrams.R b/R/give_candygrams.R index 8d71397..352dabe 100644 --- a/R/give_candygrams.R +++ b/R/give_candygrams.R @@ -6,7 +6,7 @@ #' #' @return A candy gram announcement #' -#' @importFrom stringr str_detect str_to_title +#' @importFrom stringr str_detect str_to_title str_trim #' @importFrom english as.english #' #' @export @@ -21,16 +21,20 @@ give_candygrams <- function(person, number, } - if (is.null(extra_message)) { + if (is.null(extra_message)) { extra_message <- add_commentary(person, number) - + } else { + extra_message <- glue::glue("{extra_message} {add_commentary(person, number)}") } + + + number <- str_to_title(as.english(number)) - glue::glue("{number} for {person}.") + glue::glue("{number} for {person}.") + " " + stringr::str_trim(extra_message) diff --git a/README.Rmd b/README.Rmd index d101a20..64d4815 100644 --- a/README.Rmd +++ b/README.Rmd @@ -108,4 +108,7 @@ give_candygrams("Glen Coco", 4) give_candygrams("Gretchen Weiners", 4) ``` - +```{r} +give_candygrams("Glen Coco", 4, + extra_message = "Happy Birthday.") +``` diff --git a/README.md b/README.md index 876c029..7fb8326 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,6 @@ # meangirls - The goal of meangirls is to create quotes in the style of the 2004 @@ -92,7 +91,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 +99,16 @@ 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. +``` + +``` r +give_candygrams("Glen Coco", 4, + extra_message = "Happy Birthday.") +#> Four for Glen Coco. Happy Birthday. You go, Glen Coco! ```