new_pre_release_ids {smvr} | R Documentation |
Pre-release identifiers
Description
A class representing a collection of identifiers, which are used for representing pre-release versions.
There are two functions to create the pre_release_ids vector:
-
pre_release_ids()
is a low-level constructor for creating pre-release identifiers from individual components. -
parse_pre_release_ids()
parses a character vector into pre-release identifiers.
Usage
new_pre_release_ids(...)
parse_pre_release_ids(x)
Arguments
... |
< |
x |
A character vector representing pre-release identifiers.
Each identifier separated by a dot ( |
Details
If the components are empty, they are treated as the highest precedence pre-release ids, which is used to indicate that the version is not a pre-release version.
Value
A pre_release_ids vector.
Limitations
There are some limitations on the number of identifiers in some operations:
When comparing with a string, the number of identifiers in the string. If it exceeds 5, an error is raised.
When assigning, the number of identifiers in the value being assigned. If it exceeds the number of identifiers in the target or 5, whichever is larger, an error is raised.
Please refer to the examples for details.
Examples
# Each components are concatenated with a dot
new_pre_release_ids("rc", 1:3)
ids <- parse_pre_release_ids(
c("", "alpha.beta", "alpha.1", "beta", "beta.11", "beta.2")
)
ids
# Empty ids have the highest precedence
# (Used to indicate not a pre-release version)
vctrs::vec_sort(ids)
# Can be compared with string notation
ids[ids > "beta.2"]
# Limitations:
# 1. When comparing with a string, the number of identifiers in the string
# must not exceed 5.
try(ids[ids > "beta.2.3.4.5.6"])
# This works since the string is parsed first.
ids[ids > parse_pre_release_ids("beta.2.3.4.5.6")]
# 2. When assigning, the number of identifiers in the value being assigned
# must not exceed the number of identifiers in the target or 5,
# whichever is larger.
try(ids[1] <- parse_pre_release_ids("beta.2.3.4.5.6"))