FileTemplate: File template class.

FileTemplateR Documentation

File template class.

Description

A class for reading a file template, replacing tags inside, and writing the results in an output file.

Methods

Public methods


Method new()

Initializer.

Usage
FileTemplate$new(path)
Arguments
path

The path to the template file.

Returns

Nothing.


Method replace()

Replace a tag by its value inside the template file.

Usage
FileTemplate$replace(tag, value)
Arguments
tag

The tag to replace.

value

The value to replace the tag with.

Returns

invisible(self) for chaining method calls.


Method choose()

Choose one case among a set of cases.

Usage
FileTemplate$choose(set, case)
Arguments
set

The name of the case set.

case

The name of case.

Returns

invisible(self) for chaining method calls.


Method select()

Select or remove sections that match a name.

Usage
FileTemplate$select(section, enable)
Arguments
section

The name of the section.

enable

Set to TRUE to select the section (and keep it), and FALSE to remove it.

Returns

invisible(self) for chaining method calls.


Method write()

Write template with replaced values to disk.

Usage
FileTemplate$write(path, overwrite = FALSE, checkRemainingTags = TRUE)
Arguments
path

Path to output file.

overwrite

If set to FALSE and the destination file already exists, a message is thrown. Otherwise writes into the destination.

checkRemainingTags

If set to TRUE, checks first, before writing, if there any remaining tags that have not been processed. A warning is thrown for each found tag.

Returns

Nothing.


Method getLines()

Get the lines of the templates.

Usage
FileTemplate$getLines()
Returns

A vector containing the lines of the templates.


Method clone()

The objects of this class are cloneable with this method.

Usage
FileTemplate$clone(deep = FALSE)
Arguments
deep

Whether to make a deep clone.


pkrog/biodb documentation built on Nov. 29, 2022, 4:24 a.m.