Node: R6 class representing a single node, with links to child...

Description Details Active bindings Methods

Description

R6 class representing a single node, with links to child nodes

R6 class representing a single node, with links to child nodes

Details

The node has a name, an environment that contains its attributes, and a NodeSet that contains its children, along with accessors for required functionality (determined by downstrea).

Active bindings

id

node id as string

children

NodeSet of child nodes

child_ids

character vector of child ids

attributes

node attributes

data

node data

dump

contents as a list

json

node contents as JSON

Methods

Public methods


Method new()

Used as Node$new(...) create a new node

Usage
Node$new(name, ..., .children = NodeSet$new())
Arguments
name

name of the node (arbitrary label, not checked).

...

an attributes to record (in the environment).

.children

optoinally a list of child nodes (as NodeSet)

Returns

a 'Node' object


Method matches()

Check whether this node matches conditions specified in dots

Usage
Node$matches(...)
Arguments
...

interpreted as in 'dplyr::filter' against the node attributes.

Returns

TRUE iff the tests pass


Method mutate()

Modify node attributes as specified in dots

Usage
Node$mutate(..., .which = "attributes")
Arguments
...

interpreted as in 'dplyr::mutate' against the node attributes using a data mask and quosures.

.which

either 'attributes' in which case the static node attributes are modified and a new node ID will be generated or 'data' (anything else really) and the mutable data in the node will be modified.

Returns

modified version of self


Method spawn()

Deep-clone the node and mutate node attributes as specified in dots

Usage
Node$spawn(...)
Arguments
...

interpreted as in 'dplyr::mutate' against the node attributes using a data mask and quosures.

Returns

modified version of the cloned node


Method merge()

Merge another node's child id's into this node. Only makes sense on a node with identical id's... should test that,

Usage
Node$merge(x)
Arguments
x

another Node object.

Returns

modified self


Method disown()

Clear record of child nodes, internal use

Usage
Node$disown()
Returns

self, without children


Method transform()

Create a new node using transformations described in a Transition object

Usage
Node$transform(x)
Arguments
x

transition object

Returns

a *child* object created by applying the transition


Method modify()

Modify the current node using transformations described in a Transition object

Usage
Node$modify(x)
Arguments
x

transition object

Returns

self object created by applying the transition


Method get()

Retrieve an attribute value by symbol (or character string).

Usage
Node$get(x)
Arguments
x

bare symbol or character string

Returns

value of x in node attributes


Method has()

Check for presence of attribute by symbol (or character string).

Usage
Node$has(x)
Arguments
x

bare symbol or character string

Returns

TRUE iff x exists as an attribute


Method clone()

The objects of this class are cloneable with this method.

Usage
Node$clone(deep = FALSE)
Arguments
deep

Whether to make a deep clone.


sakrejda/smgr documentation built on Sept. 1, 2020, 10:03 a.m.