Skip to content

Commit

Permalink
use fob_ instead of one_ (prefix)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kevin Cazelles committed Nov 10, 2020
1 parent 54d8ad4 commit 41137cd
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 47 deletions.
12 changes: 6 additions & 6 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

export("%+%")
export(export_answer)
export(fob_among)
export(fob_date)
export(fob_integer)
export(fob_numeric)
export(fob_text)
export(fob_word)
export(join)
export(match_pattern)
export(multi)
export(one_among)
export(one_date)
export(one_integer)
export(one_numeric)
export(one_text)
export(one_word)
importFrom(cli,style_bold)
importFrom(cli,style_underline)
importFrom(crayon,blue)
Expand Down
4 changes: 2 additions & 2 deletions R/join.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ join <- function(...) {
tmp <- list(...)
n <- length(tmp)
if (n == 1) {
out <- to_form(tmp[[1]])
out <- to_form(tmp[[1L]])
} else {
if (n > 1) {
out <- join_pair(tmp[[1]], tmp[[2]])
out <- join_pair(tmp[[1L]], tmp[[2L]])
if (n > 2) {
for (i in seq(3, n)) {
out <- join_pair(out, tmp[[i]])
Expand Down
2 changes: 1 addition & 1 deletion R/one_among.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#' @return Return the choice selected either as the choice value or its identifier (an integer).
#' @export

one_among <- function(question, choices, field_name = "", output = "choice",
fob_among <- function(question, choices, field_name = "", output = "choice",
...) {

output <- match.arg(output, c("choice", "id"))
Expand Down
26 changes: 13 additions & 13 deletions R/one_integer.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,35 +10,35 @@
#' @return Return the choice selected either as the choice value or its identifier (an integer).
#' @export

one_integer <- function(question, field_name = "", prompt = NULL) {
fob_integer <- function(question, field_name = "", prompt = NULL) {
if (is.null(prompt)) prompt <- "Enter your answer (an integer): "
generate_form_pattern(question = question, prompt = prompt,
pattern = "^[0-9]+$", confirm = FALSE, pre = NULL, post = as.integer, field_name = field_name)
}

#' @describeIn one_integer a numeric.
#' @describeIn fob_integer a numeric.
#' @export
one_numeric <- function(question, field_name = "", prompt = NULL) {
fob_numeric <- function(question, field_name = "", prompt = NULL) {
if (is.null(prompt)) prompt <- "Enter your answer (a numeric): "
generate_form_pattern(question = question, prompt = prompt,
pattern = "^[0-9]+\\.?[0-9]*$|^[0-9]*\\.?[0-9]+$", confirm = FALSE,
pre = NULL, post = as.numeric, field_name = field_name)
}


#' @describeIn one_integer a word.
#' @describeIn fob_integer a word.
#' @export
one_word <- function(question, field_name = "", prompt = NULL) {
fob_word <- function(question, field_name = "", prompt = NULL) {
if (is.null(prompt)) prompt <- "Enter your answer (one word): "
generate_form_pattern(question = question, prompt = prompt,
pattern = "^[A-Za-z\\-]+$", pre = NULL, post = NULL, confirm = FALSE,
field_name = field_name)
}


#' @describeIn one_integer a text.
#' @describeIn fob_integer a text.
#' @export
one_text <- function(question, field_name = "", max = NULL, prompt = NULL, ...) {
fob_text <- function(question, field_name = "", max = NULL, prompt = NULL, ...) {

if (is.null(prompt)) {
if (is.null(max)) {
Expand Down Expand Up @@ -66,9 +66,9 @@ one_text <- function(question, field_name = "", max = NULL, prompt = NULL, ...)
}


#' @describeIn one_integer a date.
#' @describeIn fob_integer a date.
#' @export
one_date <- function(question, field_name = "", format = "%Y-%m-%d",
fob_date <- function(question, field_name = "", format = "%Y-%m-%d",
prompt = NULL, ...) {

if (is.null(prompt))
Expand All @@ -82,9 +82,9 @@ one_date <- function(question, field_name = "", format = "%Y-%m-%d",
}


#' @describeIn one_integer `TRUE` for yes and `FALSE` for no.
#' @describeIn fob_integer `TRUE` for yes and `FALSE` for no.

one_yorn <- function(question, field_name = "",
fob_yorn <- function(question, field_name = "",
prompt = "Enter [Y]es or [N]o: ", ...) {

f_post <- function(x) grepl("^Y", x)
Expand All @@ -102,9 +102,9 @@ one_yorn <- function(question, field_name = "",
}


#' @describeIn one_integer one boolean/logical (i.e. `TRUE` or `FALSE`).
#' @describeIn fob_integer one boolean/logical (i.e. `TRUE` or `FALSE`).

one_boolean <- function(question, field_name = "",
fob_boolean <- function(question, field_name = "",
prompt = "Enter [T]RUE or [F]ALSE: ", ...) {

f_post <- function(x) grepl("^T", x)
Expand Down
6 changes: 3 additions & 3 deletions man/one_among.Rd → man/fob_among.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

42 changes: 21 additions & 21 deletions man/one_integer.Rd → man/fob_integer.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion tests/testthat/test_basic.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ q2 <- one_yorn("Be or not to be", "shake")
q3 <- one_date("When was that?", "date")
q4 <- match_pattern("2 letters + 1 digit", "^[A-Za-z]{2}[0-9]$")
myform <- q1 %+% q2 %+% q3 %+% q4
# res <- myform()
# res <- myform()

0 comments on commit 41137cd

Please sign in to comment.