base_class: base_class

base_classR Documentation

base_class

Description

R6 class for providing additional default R6 class features

Value

a base_class class (R6 class)

Methods

Public methods


Method new()

Usage
base_class$new(argList = NULL, ...)
Arguments
argList

A 'List' of name/value pairs to be passed in as arguments.

...

Name/Value pairs as arguments.

Returns

none Nothing is returned

Dump object values

Convenient for debugging private class values (puts var named tmpVar in global environment)


Method dump()

Usage
base_class$dump()
Returns

private The private environment of the object

Examples
obj = some_R6_class$new()
obj$dump()
data = tmpVar$some_private_var_name
data = tmpVar[["some_private_var_name"]]

Get variable

Gets a private variables value.


Method get_var()

Usage
base_class$get_var(var_name)
Arguments
var_name

The name of the private variable to return.

Returns

var The value of the requested variable.

Examples
obj = some_R6_class$new()
var_value = obj$get_var("var_name")

Set variable

Sets a private variables value.
This method is chainable.


Method set_var()

Usage
base_class$set_var(var_name, var_value)
Arguments
var_name

The name of the private variable to set.

var_value

The value to assign to the desired private variable.

Returns

object_ref The reference to the original object.

Examples
obj = some_R6_class$new()
obj$set_var("var_name", var_value)


Method clone()

The objects of this class are cloneable with this method.

Usage
base_class$clone(deep = FALSE)
Arguments
deep

Whether to make a deep clone.

Examples


new_class = R6::R6Class(
  "new_class",
  inherit = base_class,
  portable = TRUE,

  public = list(
    ...
  ),
  private = list(
    ...
  )
)

Initialize object

Allow list based function initialization (easier to integrate with config files)


## ------------------------------------------------
## Method `base_class$dump`
## ------------------------------------------------


obj = some_R6_class$new()
obj$dump()
data = tmpVar$some_private_var_name
data = tmpVar[["some_private_var_name"]]

Get variable

Gets a private variables value.


## ------------------------------------------------
## Method `base_class$get_var`
## ------------------------------------------------


obj = some_R6_class$new()
var_value = obj$get_var("var_name")

Set variable

Sets a private variables value.
This method is chainable.


## ------------------------------------------------
## Method `base_class$set_var`
## ------------------------------------------------


obj = some_R6_class$new()
obj$set_var("var_name", var_value)


namc-utah/NAMCr documentation built on Feb. 12, 2024, 4:29 a.m.