Class: TXTextControl::ReportingCloud::MergeBlock
- Inherits:
-
Object
- Object
- TXTextControl::ReportingCloud::MergeBlock
- Defined in:
- lib/txtextcontrol/reportingcloud/merge_block.rb
Overview
Represents a merge block in a document template.
Instance Attribute Summary collapse
-
#merge_blocks ⇒ Array<MergeBlock>
readonly
The merge blocks nested inside the merge block.
-
#merge_fields ⇒ Array<MergeField>
readonly
The merge fields inside the merge block.
-
#name ⇒ String
readonly
The merge block's' name.
Class Method Summary collapse
-
.from_camelized_hash(hash) ⇒ MergeBlock
Creates an MergeBlock instance from a hash.
Instance Method Summary collapse
-
#initialize(name, merge_blocks, merge_fields) ⇒ MergeBlock
constructor
A new instance of MergeBlock.
Constructor Details
#initialize(name, merge_blocks, merge_fields) ⇒ MergeBlock
Returns a new instance of MergeBlock
30 31 32 33 34 35 36 37 38 39 |
# File 'lib/txtextcontrol/reportingcloud/merge_block.rb', line 30 def initialize(name, merge_blocks, merge_fields) # Parameter validation raise ArgumentError, "Block name must be a string." if !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 @name = name @merge_blocks = merge_blocks @merge_fields = merge_fields end |
Instance Attribute Details
#merge_blocks ⇒ Array<MergeBlock> (readonly)
The merge blocks nested inside the merge block.
25 26 27 |
# File 'lib/txtextcontrol/reportingcloud/merge_block.rb', line 25 def merge_blocks @merge_blocks end |
#merge_fields ⇒ Array<MergeField> (readonly)
The merge fields inside the merge block.
25 26 27 |
# File 'lib/txtextcontrol/reportingcloud/merge_block.rb', line 25 def merge_fields @merge_fields end |
#name ⇒ String (readonly)
The merge block's' name.
25 26 27 |
# File 'lib/txtextcontrol/reportingcloud/merge_block.rb', line 25 def name @name end |
Class Method Details
.from_camelized_hash(hash) ⇒ MergeBlock
Creates an MergeBlock instance from a hash.
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/txtextcontrol/reportingcloud/merge_block.rb', line 44 def self.from_camelized_hash(hash) # Parameter validation raise ArgumentError, "Parameter must be a Hash." if !hash.kind_of? Hash name = hash["name"] 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 MergeBlock.new(name, blocks, fields) end |