Description Usage Arguments Value Active bindings Methods Author(s) See Also Examples
Blueprint is the root super-class of all R6 classes of package blueprint and provides important low-level mechanisms. All classes of blueprint inherit class Blueprint.
This class is definitely not useful for typical users. You should consider it a virtual class.
1 2 3 4 5 | ## Test if an object is a 'Blueprint' object
is_blueprint(x)
## Validate if an object is a proper 'Blueprint' object
valid_blueprint(x)
|
x |
any R object. |
External helper function is_blueprint()
returns a logical scalar.
External helper function valid_blueprint()
returns a logical scalar if
the object is valid. Else, an error explaining what is wrong is returned.
is_blueprint
A scalar logical always equal to TRUE.
version
A scalar character that registers blueprint's version at the moment the object is created.
new()
Create a new Blueprint object.
Blueprint$new()
A R6 object of class Blueprint.
validate()
Validate a Blueprint object.
Blueprint$validate()
The Blueprint object invisibly if the object is valid. Else, an error explaining what is wrong with the object.
print()
Print a Blueprint object.
Blueprint$print()
The object is automatically validated before being printed.
The Blueprint object invisibly.
format()
Format a Blueprint object.
Blueprint$format()
A character scalar representing the formatted Blueprint object.
get()
Extract a field's value from a Blueprint object.
Blueprint$get(field = character(), .validate = TRUE)
field
A scalar character. The name of a field.
.validate
A scalar logical. Validate the object before calling the method? While this argument is available to the users, it should be ignored, unless you have an alternative way to make sure your underlying object is valid. Since it is a low-level argument, it is not validated, so proceed with care.
The value corresponding to the chosen field
. If it
does not exist, NULL
is returned. If field
is missing,
the underlying Blueprint object is returned invisibly.
## Get a field, here 'version'. Blueprint$new()$get("version") ## Extract a non-existent field, here 'nope'. NULL is returned. Blueprint$new()$get("nope") ## Just return the whole object (is a functional style). ## The output is invisible, we must print it to see it. Blueprint$new()$get()$print()
set()
Update a field's value of a Blueprint object.
Blueprint$set(field = character(), value, .validate = TRUE)
field
A scalar character. The name of a field.
value
Any R value. The value to use when updating a field. Its type must match the field's underlying structure.
.validate
A scalar logical. Validate the object before calling the method? While this argument is available to the users, it should be ignored, unless you have an alternative way to make sure your underlying object is valid. Since it is a low-level argument, it is not validated, so proceed with care.
Beware! Class Blueprint has no modifiable fields.
The Blueprint object invisibly if the object is valid. Else, an error explaining what is wrong with the object.
## Trying to update a non-public field throws an error! \dontrun{ Blueprint$new()$set("version", "1.0.0") }
Jean-Mathieu Potvin (jm@potvin.xyz)
Other Blueprint classes:
Atomic
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | ## ------------------------------------------------
## Method `Blueprint$get`
## ------------------------------------------------
## Get a field, here 'version'.
Blueprint$new()$get("version")
## Extract a non-existent field, here 'nope'. NULL is returned.
Blueprint$new()$get("nope")
## Just return the whole object (is a functional style).
## The output is invisible, we must print it to see it.
Blueprint$new()$get()$print()
## ------------------------------------------------
## Method `Blueprint$set`
## ------------------------------------------------
## Trying to update a non-public field throws an error!
## Not run:
Blueprint$new()$set("version", "1.0.0")
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.