ObjectReferenceYamlParsed.S3: Class: ObjectReferenceYamlParsed.S3

Description Usage Arguments Value Fields Intended use of this class Author(s) References See Also Examples

Description

Class representing parsed YAML markup as returned by function parseYaml in the context of reactive references and its constructor function.

Usage

1
2
ObjectReferenceYamlParsed.S3(.x, original = character(), parsed = list(id =
  character, where = NULL, as = NULL), index = numeric(), src = NULL)

Arguments

.x

ANY. An object of an arbitrary class whose class attribute should be updated so that it becomes an instance of class ObjectReferenceYamlParsed.S3. Mainly intended for rapid prototyping purposes

Value

Instance of class ObjectReferenceYamlParsed.S3.

Fields

original

character. YAML markup as identified by getYaml Initial: character().

parsed

list. Parsed YAML markup as identified by getYaml and parsed by parseYaml. Initial: list(id = character, where = NULL, as = NULL).

index

numeric. Index denoting the lines/expressions that where YAML was identified. These lines/expressions will later be substituted by suitable expressions. Initial: numeric().

src

ANY. Object in which YAML markup was identified. Typcially, this corresponds to a function or expression, but it can generally be any R object that can contain YAML markup and for which methods for getYaml are defined. Initial: NULL.

Intended use of this class

This S3 class, or to be more precise its constructor function, exists mainly for rapid prototyping purposes. This is mainly reflected in the fact, that when specifying .x, this constructor function will simply update the class attribute of whatever object has been provided.

However, it also allows for a more formal OOP-style of rapid prototyping by offering explicit class fields (all arguments except .x). Nevertheless, it is probably advisable to switch to an explicit formal approach such as S4 and/or Reference Classes once the package or application has reached a certain state of maturity.

Author(s)

Janko Thyson janko.thyson@rappster.de

References

http://github.com/Rappster/yamlr

See Also

ObjectReferenceYaml.S3, getYaml, parseYaml

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
## Not run: 

## Example YAML //
yaml <- getYaml(
  from = function() {
    "object-ref: {id: x_1, where:.GlobalEnv, as: ref_1}"
    ref_1
  },
  ctx = YamlContext.ObjectReference.S3()  
)  
  
## Informal use (intended mainly for rapid prototyping) //
## Takes *any* object and simply changes the class attributes
ObjectReferenceYamlParsed.S3(
  list(
    original = yaml$original,
    parsed = list(
      id = "x_1", 
      where = as.name("where"), 
      as = as.name("ref_1"),
      index = 2
    ),
    index = yaml$index,
    src = yaml$src
  )
)  
ObjectReferenceYamlParsed.S3(TRUE)  

## Formal use (explicitly using 'fields') //
res <- ObjectReferenceYamlParsed.S3()
ls(res)
res <- ObjectReferenceYamlParsed.S3(
  original = yaml$original,
  parsed = list(
    id = "x_1", 
    where = as.name("where"), 
    as = as.name("ref_1"),
    index = 2
  ),
  index = yaml$index,
  src = yaml$src
)
res$original
res$parsed
res$index
res$src

## Recommended: include namespace //
## Regardless if you plan on using this class in an informal or formal way
yamlr::ObjectReferenceYamlParsed.S3()


## End(Not run)

rappster/yamlr documentation built on May 27, 2019, 2:02 a.m.