Description Usage Arguments Format Details Examples
These function manage adding class defining functions and testing if an id is associated with a class definition or if is contained in the class definition.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | pd_class_definitions
pd_is_class_definition(id, pd, .check = TRUE)
pd_is_in_class_definition(id, pd, .check = TRUE)
pd_add_class_definition(
name,
test.is,
test.in,
.exists = TRUE,
.overwrite = FALSE
)
pd_add_class(name, .exists = TRUE, .overwrite = FALSE)
|
id |
id(s) to test. |
pd |
parse data which contains id. |
.check |
should the id, and pd be checked? |
name |
name of the class defining function |
test.is |
function accepting arguments |
test.in |
function accepting arguments |
.exists |
require the function to exists to add. |
.overwrite |
if TRUE allows for overwriting existing test functions. |
An object of class environment
of length 12.
pd_class_definitions$has
1 2 | pd_class_definitions$has(name)
|
Check if a class defining function has 'is' and 'in' function defined for it.
pd_class_definitions$add
or pd_add_class
1 2 3 | pd_class_definitions$add(name, .exists=TRUE, .overwrite=FALSE)
pd_add_class(name, .exists=TRUE, .overwrite=FALSE)
|
Add a def with default 'is' and 'in' functions defined.
pd_class_definitions$add_definition
or pd_add_class_definition
1 2 3 | pd_class_definitions$add_definition(name, test.is, test.in, .exists=TRUE, .overwrite=FALSE)
pd_add_class_definition(name, test.is, test.in, .exists=TRUE, .overwrite=FALSE)
|
Add a class defining function with custom 'is' and 'in' functions defined.
pd_class_definitions$rm
1 |
Remove the testing functions for the class.
pd_class_definitions$names
1 |
Return a vector of the classed for which tests are defined.
pd_class_definitions$test_is
1 | pd_class_definitions$test_is(id, pd, check=TRUE)
|
Test if id
is associated with each of
defined class definitions.
pd_class_definitions$test_is_in
1 | pd_class_definitions$test_is_in(id, pd, check=TRUE)
|
Test if id
is contained within each of
defined class definitions.
pd_class_definitions$which
1 | pd_class_definitions$which(id, pd, check=TRUE)
|
Return the name of the class, if any,
which id
corresponds to.
pd_class_definitions$in_which
1 | pd_class_definitions$in_which(id, pd, check=TRUE)
|
Returns a vector of the classes, if any,
of the classes which id
is contained in.
pd_is_class_definition
Returns TRUE
if the id corresponds to any of the
class defining calls.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | # load example file and get_parse data
ex.file <- system.file("examples", "example.R", package="parsetools")
exprs <- parse(ex.file, keep.source = TRUE)
pd <- get_parse_data(exprs)
# There are 3 expressions so there should be three roots.
sum(pd_is_root(pd$id, pd))
roots <- pd_all_root_ids(pd)
# Get the 'setClass' call.
class.id <- pd_get_assign_value_id(roots[2], pd)
# Check to make sure that it is a function that sets a class.
pd_is_class_definition(class.id, pd)
# and that it is the setClass call.
pd_text(pd_get_call_symbol_id(class.id, pd), pd)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.