-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #19 from poissonconsulting/f-title
- Loading branch information
Showing
51 changed files
with
774 additions
and
181 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,21 @@ | ||
# Generated by roxygen2: do not edit by hand | ||
|
||
export("tmr_title<-") | ||
export(local_timer) | ||
export(tmr_ceiling) | ||
export(tmr_elapsed) | ||
export(tmr_floor) | ||
export(tmr_format) | ||
export(tmr_is_started) | ||
export(tmr_is_stopped) | ||
export(tmr_is_titled) | ||
export(tmr_print) | ||
export(tmr_reset) | ||
export(tmr_round) | ||
export(tmr_start) | ||
export(tmr_stop) | ||
export(tmr_timer) | ||
export(tmr_title) | ||
export(with_timer) | ||
import(hms) | ||
importFrom(lifecycle,deprecated) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#' Is hms Timer Title | ||
#' | ||
#' Tests if a [hms_timer()] has a title (as indicated by the | ||
#' presence of an attribute named start). | ||
#' @inheritParams params | ||
#' @return A flag (TRUE or FALSE). | ||
#' @export | ||
#' @examples | ||
#' tmr_is_titled(tmr_timer()) | ||
#' tmr_is_titled(tmr_timer(title = "my timer")) | ||
tmr_is_titled <- function(x) { | ||
tmr_title(x) != "" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,29 @@ | ||
#' Parameter Descriptions for hmstimer Functions | ||
#' Parameter Descriptions | ||
#' | ||
#' @param .local_envir The environment to use for scoping. | ||
#' @param code Code to time. | ||
#' @param digits A whole number of the number of decimal places. | ||
#' Default parameter descriptions which may be overridden in individual | ||
#' functions. | ||
#' | ||
#' A flag is a non-missing logical scalar. | ||
#' | ||
#' A string is a non-missing character scalar. | ||
#' | ||
#' A count is a non-missing non-negative integer scalar or double | ||
#' scalar with no fractional part. | ||
# | ||
#' @param code A line or block of R code. | ||
#' @param digits A count of the number of decimal places. | ||
#' @param print_title A flag specifying whether to print the title. | ||
#' @param seconds A non-negative numeric scalar of the initial number of seconds. | ||
#' @param start A flag indicating whether to start the timer. | ||
#' @param srcref A flag specifying whether to print the source reference. | ||
#' @param start A flag specifying whether to start the timer. | ||
#' @param title A string of the title. | ||
#' @param value A string of the title. | ||
#' @param x A [hms_timer()]. | ||
#' @param .local_envir The environment to use for scoping. | ||
#' @inheritParams rlang::args_dots_empty | ||
#' @keywords internal | ||
#' @name params | ||
NULL | ||
#' @aliases parameters arguments args | ||
#' @usage NULL | ||
# nocov start | ||
params <- function(...) NULL | ||
# nocov end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#' Get Title hms Timer | ||
#' | ||
#' Returns a flag (character vector) of the title. | ||
#' | ||
#' @inheritParams params | ||
#' @return A flag of the title. | ||
#' @seealso [tmr_title<-()] | ||
#' @export | ||
#' @examples | ||
#' tmr_title(tmr_timer()) | ||
#' tmr_title(tmr_timer(title = "")) | ||
#' tmr_title(tmr_timer(title = "A Title")) | ||
tmr_title <- function(x) { | ||
title <- attr(x, "title") | ||
if (is.null(title)) { | ||
return("") | ||
} | ||
unname(title) | ||
} | ||
|
||
#' Set Title hms Timer | ||
#' | ||
#' Sets the title of a [hms_timer()]. | ||
#' | ||
#' @inheritParams params | ||
#' @return A copy of the [hms_timer()] with the new title. | ||
#' @seealso [tmr_title()] | ||
#' @export | ||
#' @examples | ||
#' tmr <- tmr_timer(title = "A title") | ||
#' tmr_print(tmr) | ||
#' tmr_title(tmr) <- "A different title" | ||
#' tmr_print(tmr) | ||
#' tmr_title(tmr) <- NULL | ||
#' tmr_print(tmr) | ||
`tmr_title<-` <- function(x, value) { | ||
chk_title(value) | ||
value <- unname(value) | ||
attr(x, "title") <- value | ||
x | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,14 @@ | ||
is.hms <- function(x) inherits(x, "hms") | ||
as_hms <- function(x) { | ||
hms::new_hms(x) | ||
} | ||
|
||
err <- function(...) stop(..., call. = FALSE) | ||
|
||
wrn <- function(...) warning(..., call. = FALSE) | ||
|
||
paste_title <- function(x, title) { | ||
if (is.null(title) || !nchar(title)) { | ||
return(x) | ||
} | ||
paste0(x, " [", title, "]") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.