Class: DynamicPDFApi::Template
- Inherits:
-
Object
- Object
- DynamicPDFApi::Template
- Defined in:
- lib/ruby_client/Template.rb
Overview
Represents a document template.
Instance Attribute Summary collapse
-
#elements ⇒ Object
Gets or sets the elements for the template.
-
#id ⇒ Object
Gets or sets the id for the template.
Instance Method Summary collapse
-
#initialize(id) ⇒ Template
constructor
Initializes a new instance of the Template class.
- #to_json(_options = {}) ⇒ Object
Constructor Details
#initialize(id) ⇒ Template
Initializes a new instance of the Template class.
11 12 13 14 15 16 17 18 |
# File 'lib/ruby_client/Template.rb', line 11 def initialize(id) @id = if id.nil? SecureRandom.uuid else id end @elements = [] end |
Instance Attribute Details
#elements ⇒ Object
Gets or sets the elements for the template.
28 29 30 |
# File 'lib/ruby_client/Template.rb', line 28 def elements @elements end |
#id ⇒ Object
Gets or sets the id for the template.
23 24 25 |
# File 'lib/ruby_client/Template.rb', line 23 def id @id end |
Instance Method Details
#to_json(_options = {}) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/ruby_client/Template.rb', line 30 def to_json( = {}) elements = [] @elements.each do |element| str = element unless element.nil? elements << str unless str.nil? end json_array = {} json_array['id'] = @id json_array['elements'] = @elements JSON.pretty_generate(json_array) end |