enum: Enum objects

Description Usage Arguments Details Value Examples

View source: R/enum_class.R

Description

A base class in the struct package. Not normally called directly.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
enum(
  name,
  description = character(0),
  type = "character",
  value = character(0),
  max_length = 1,
  allowed,
  ...
)

## S4 replacement method for signature 'enum'
value(obj) <- value

Arguments

name

the name of the object

description

a description of the object

type

the type of the struct object

value

value of the enum

max_length

Maximum length of value vector (default 1)

allowed

A list of allowed values

...

additional inputs to the struct_class object

obj

an enum object

Details

An enum object is a special type of entity object that ensures the value must be one from a list of allowed values.

Enum objects are usually defined in the prototype of another object, but can be extracted using param_obj and output_obj.

Value

an enum object

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
# Create a new enum object
E = enum(
    name = 'example',
    description = 'this is an example',
    type = 'character',
    value = 'hello',
    allowed = c('hello','world')
)

# Get/set the value of the entity object
value(E)
value(E) = 'world'

computational-metabolomics/struct documentation built on Nov. 17, 2021, 8:57 a.m.