set_obj_show: a helper function to update the show method for a struct...

Description Usage Arguments Value Examples

View source: R/struct_class.R

Description

a helper function to update the show method for a struct object

Usage

1
set_obj_show(class_name, extra_string, where = topenv(parent.frame()))

Arguments

class_name

the name of the to update the method for

extra_string

a function that returns an extra string using the input object as an input e.g. function(object)return = 'extra_string'

where

the environment to create the object in. default where = topenv(parent.frame())

Value

a method is created in the specified environment

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
# create an example object first
set_struct_obj(
class_name = 'add_two_inputs',
struct_obj = 'model',
stato = FALSE,
params = c(input_1 = 'numeric', input_2 = 'numeric'),
outputs = c(result = 'numeric'),
prototype = list(
   input_1 = 0,
   input_2 = 0,
   name = 'Add two inputs',
   description = 'example class that adds two values together')
)

# now update the method
set_obj_show(
class_name = 'add_two_inputs',
extra_string = function(object) {return('The extra text')}
)

struct documentation built on Nov. 8, 2020, 8:14 p.m.