class Proforma::Template
A Template
instance is a set of modeling objects with directions on how to compile it into a Prototype
object. The prototype instance can then be rendered into an end-result such as a text, pdf, or spreadsheet file.
Attributes
split[W]
Public Class Methods
new(children: [], split: false, title: '')
click to toggle source
Calls superclass method
Proforma::Prototype::new
# File lib/proforma/template.rb, line 20 def initialize(children: [], split: false, title: '') @split = split super(children: children, title: title) end
Public Instance Methods
compile(data, evaluator)
click to toggle source
# File lib/proforma/template.rb, line 31 def compile(data, evaluator) if split? compile_record(data, evaluator) else compile_collection(data, evaluator) end end
split()
click to toggle source
# File lib/proforma/template.rb, line 26 def split @split || false end
Also aliased as: split?
Private Instance Methods
compile_collection(data, evaluator)
click to toggle source
# File lib/proforma/template.rb, line 41 def compile_collection(data, evaluator) compiled_children = Modeling::Collection.new(children: children).compile(data, evaluator) [ Prototype.new( children: compiled_children, title: evaluator.text({}, title) ) ] end
compile_record(data, evaluator)
click to toggle source
# File lib/proforma/template.rb, line 52 def compile_record(data, evaluator) default_grouping = Modeling::Grouping.new(children: children) array(data).map do |record| compiled_children = default_grouping.compile(record, evaluator) Prototype.new( children: compiled_children, title: evaluator.text(record, title) ) end end