Class: TXTextControl::ReportingCloud::TemplateInfo
- Inherits:
-
Object
- Object
- TXTextControl::ReportingCloud::TemplateInfo
- Defined in:
- lib/txtextcontrol/reportingcloud/template_info.rb
Overview
Holds information about the merge blocks and merge fields in a template
in the template storage.
Instance Attribute Summary collapse
-
#merge_blocks ⇒ Array<MergeBlock>
readonly
Contains all top level merge blocks in the template.
-
#merge_fields ⇒ Array<MergeField>
readonly
Contains all top level merge fields in the template.
-
#template_name ⇒ String
readonly
The template file name.
Class Method Summary collapse
-
.from_camelized_hash(hash) ⇒ TemplateInfo
Creates a TemplateInfo instance from a hash.
Instance Method Summary collapse
-
#initialize(template_name, merge_blocks, merge_fields) ⇒ TemplateInfo
constructor
A new instance of TemplateInfo.
Constructor Details
#initialize(template_name, merge_blocks, merge_fields) ⇒ TemplateInfo
Returns a new instance of TemplateInfo
36 37 38 39 40 41 42 43 44 45 |
# File 'lib/txtextcontrol/reportingcloud/template_info.rb', line 36 def initialize(template_name, merge_blocks, merge_fields) # Parameter validation raise ArgumentError, "Block name must be a string." if !template_name.kind_of? String raise ArgumentError, "Parameter merge_blocks must be an array." if !merge_blocks.kind_of? Array raise ArgumentError, "Parameter merge_fields must be an array." if !merge_fields.kind_of? Array @template_name = template_name @merge_blocks = merge_blocks @merge_fields = merge_fields end |
Instance Attribute Details
#merge_blocks ⇒ Array<MergeBlock> (readonly)
Contains all top level merge blocks in the template.
28 29 30 |
# File 'lib/txtextcontrol/reportingcloud/template_info.rb', line 28 def merge_blocks @merge_blocks end |
#merge_fields ⇒ Array<MergeField> (readonly)
Contains all top level merge fields in the template.
28 29 30 |
# File 'lib/txtextcontrol/reportingcloud/template_info.rb', line 28 def merge_fields @merge_fields end |
#template_name ⇒ String (readonly)
The template file name.
28 29 30 |
# File 'lib/txtextcontrol/reportingcloud/template_info.rb', line 28 def template_name @template_name end |
Class Method Details
.from_camelized_hash(hash) ⇒ TemplateInfo
Creates a TemplateInfo instance from a hash.
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/txtextcontrol/reportingcloud/template_info.rb', line 50 def self.from_camelized_hash(hash) # Parameter validation raise ArgumentError, "Parameter must be a Hash." if !hash.kind_of? Hash name = hash["templateName"] blocks = Array.new hash["mergeBlocks"].each do |elem| blocks.push(MergeBlock.from_camelized_hash(elem)) end fields = Array.new hash["mergeFields"].each do |elem| fields.push(MergeField.from_camelized_hash(elem)) end return TemplateInfo.new(name, blocks, fields) end |