Class: TXTextControl::ReportingCloud::MergeField
- Inherits:
-
Object
- Object
- TXTextControl::ReportingCloud::MergeField
- Defined in:
- lib/txtextcontrol/reportingcloud/merge_field.rb
Overview
Represents a merge field in a document template.
Instance Attribute Summary collapse
-
#date_time_format ⇒ String
readonly
The format which is applied to date / time values.
-
#name ⇒ String
readonly
The name of the field.
-
#numeric_format ⇒ String
readonly
The format which is applied to numeric values.
-
#preserve_formatting ⇒ Boolean
readonly
Specifies whether formatting is preserved.
-
#text ⇒ String
readonly
The field text.
-
#text_after ⇒ String
readonly
The text after the field.
-
#text_before ⇒ String
readonly
The text before the field.
Class Method Summary collapse
-
.from_camelized_hash(hash) ⇒ MergeField
Creates an MergeField instance from a hash.
Instance Method Summary collapse
-
#initialize(date_time_format, name, numeric_format, preserve_formatting, text, text_after, text_before) ⇒ MergeField
constructor
A new instance of MergeField.
Constructor Details
#initialize(date_time_format, name, numeric_format, preserve_formatting, text, text_after, text_before) ⇒ MergeField
Returns a new instance of MergeField
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/txtextcontrol/reportingcloud/merge_field.rb', line 37 def initialize(date_time_format, name, numeric_format, preserve_formatting, text, text_after, text_before) # Parameter validation unless date_time_format.nil? || (date_time_format.kind_of? String) raise ArgumentError, "Date / time format must be a string." end raise ArgumentError, "Field name must be a string." if !name.kind_of? String unless numeric_format.nil? || (numeric_format.kind_of? String) raise ArgumentError, "Numeric format must be a string" end raise ArgumentError, "Preserve formatting parameter must be a boolean value." if !!preserve_formatting != preserve_formatting raise ArgumentError, "Field text must be a string." if !text.kind_of? String raise ArgumentError, "Text after must be a string." if !text_after.nil? && (!text_after.kind_of? String) raise ArgumentError, "Text before must be a string." if !text_before.nil? && (!text_before.kind_of? String) @date_time_format = date_time_format @name = name @numeric_format = numeric_format @preserve_formatting = preserve_formatting @text = text @text_after = text_after @text_before = text_before end |
Instance Attribute Details
#date_time_format ⇒ String (readonly)
The format which is applied to date / time values.
28 29 30 |
# File 'lib/txtextcontrol/reportingcloud/merge_field.rb', line 28 def date_time_format @date_time_format end |
#name ⇒ String (readonly)
The name of the field.
28 29 30 |
# File 'lib/txtextcontrol/reportingcloud/merge_field.rb', line 28 def name @name end |
#numeric_format ⇒ String (readonly)
The format which is applied to numeric values.
28 29 30 |
# File 'lib/txtextcontrol/reportingcloud/merge_field.rb', line 28 def numeric_format @numeric_format end |
#preserve_formatting ⇒ Boolean (readonly)
Specifies whether formatting is preserved.
28 29 30 |
# File 'lib/txtextcontrol/reportingcloud/merge_field.rb', line 28 def preserve_formatting @preserve_formatting end |
#text ⇒ String (readonly)
The field text.
28 29 30 |
# File 'lib/txtextcontrol/reportingcloud/merge_field.rb', line 28 def text @text end |
#text_after ⇒ String (readonly)
The text after the field.
28 29 30 |
# File 'lib/txtextcontrol/reportingcloud/merge_field.rb', line 28 def text_after @text_after end |
#text_before ⇒ String (readonly)
The text before the field.
28 29 30 |
# File 'lib/txtextcontrol/reportingcloud/merge_field.rb', line 28 def text_before @text_before end |
Class Method Details
.from_camelized_hash(hash) ⇒ MergeField
Creates an MergeField instance from a hash.
63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/txtextcontrol/reportingcloud/merge_field.rb', line 63 def self.from_camelized_hash(hash) # Parameter validation raise ArgumentError, "Parameter must be a Hash." if !hash.kind_of? Hash date_time_format = hash["dateTimeFormat"] name = hash["name"] numeric_format = hash["numericFormat"] preserve_formatting = hash["preserveFormatting"] text = hash["text"] text_after = hash["textAfter"] text_before = hash["textBefore"] return MergeField.new(date_time_format, name, numeric_format, preserve_formatting, text, text_after, text_before) end |