aspose_pdf_cloud 19.2.0 → 19.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (40) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +35 -5
  3. data/docs/CellRecognized.md +10 -0
  4. data/docs/ImageStamp.md +25 -0
  5. data/docs/PdfApi.md +419 -3
  6. data/docs/PdfPageStamp.md +24 -0
  7. data/docs/Position.md +10 -0
  8. data/docs/RowRecognized.md +10 -0
  9. data/docs/StampBase.md +22 -0
  10. data/docs/StampInfo.md +16 -0
  11. data/docs/StampsInfo.md +10 -0
  12. data/docs/StampsInfoResponse.md +11 -0
  13. data/docs/TableRecognized.md +13 -0
  14. data/docs/TableRecognizedResponse.md +11 -0
  15. data/docs/TablesRecognized.md +10 -0
  16. data/docs/TablesRecognizedResponse.md +11 -0
  17. data/docs/TextRect.md +6 -1
  18. data/docs/TextStamp.md +25 -0
  19. data/lib/aspose_pdf_cloud.rb +14 -0
  20. data/lib/aspose_pdf_cloud/api/pdf_api.rb +1450 -204
  21. data/lib/aspose_pdf_cloud/models/cell_recognized.rb +211 -0
  22. data/lib/aspose_pdf_cloud/models/image_stamp.rb +363 -0
  23. data/lib/aspose_pdf_cloud/models/pdf_page_stamp.rb +353 -0
  24. data/lib/aspose_pdf_cloud/models/position.rb +221 -0
  25. data/lib/aspose_pdf_cloud/models/row_recognized.rb +213 -0
  26. data/lib/aspose_pdf_cloud/models/stamp_base.rb +333 -0
  27. data/lib/aspose_pdf_cloud/models/stamp_info.rb +273 -0
  28. data/lib/aspose_pdf_cloud/models/stamps_info.rb +215 -0
  29. data/lib/aspose_pdf_cloud/models/stamps_info_response.rb +226 -0
  30. data/lib/aspose_pdf_cloud/models/table_recognized.rb +245 -0
  31. data/lib/aspose_pdf_cloud/models/table_recognized_response.rb +226 -0
  32. data/lib/aspose_pdf_cloud/models/tables_recognized.rb +215 -0
  33. data/lib/aspose_pdf_cloud/models/tables_recognized_response.rb +226 -0
  34. data/lib/aspose_pdf_cloud/models/text_rect.rb +54 -9
  35. data/lib/aspose_pdf_cloud/models/text_stamp.rb +363 -0
  36. data/lib/aspose_pdf_cloud/version.rb +1 -1
  37. data/test/pdf_tests.rb +260 -3
  38. data/test_data/PageNumberStamp.pdf +0 -0
  39. data/test_data/PdfWithTable.pdf +0 -0
  40. metadata +32 -2
@@ -0,0 +1,353 @@
1
+ =begin
2
+ --------------------------------------------------------------------------------------------------------------------
3
+ Copyright (c) 2019 Aspose.PDF Cloud
4
+ Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ of this software and associated documentation files (the "Software"), to deal
6
+ in the Software without restriction, including without limitation the rights
7
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ copies of the Software, and to permit persons to whom the Software is
9
+ furnished to do so, subject to the following conditions:
10
+ The above copyright notice and this permission notice shall be included in all
11
+ copies or substantial portions of the Software.
12
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
13
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
14
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
15
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
16
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
17
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
18
+ SOFTWARE.
19
+ --------------------------------------------------------------------------------------------------------------------
20
+ =end
21
+
22
+ require 'date'
23
+ require 'time'
24
+
25
+ module AsposePdfCloud
26
+ # Represents Pdf stamps.
27
+ class PdfPageStamp
28
+ # Link to the document.
29
+ attr_accessor :links
30
+
31
+ # Sets or gets a bool value that indicates the content is stamped as background. If the value is true, the stamp content is layed at the bottom. By defalt, the value is false, the stamp content is layed at the top.
32
+ attr_accessor :background
33
+
34
+ # Gets or sets bottom margin of stamp.
35
+ attr_accessor :bottom_margin
36
+
37
+ # Gets or sets Horizontal alignment of stamp on the page.
38
+ attr_accessor :horizontal_alignment
39
+
40
+ # Gets or sets left margin of stamp.
41
+ attr_accessor :left_margin
42
+
43
+ # Gets or sets a value to indicate the stamp opacity. The value is from 0.0 to 1.0. By default the value is 1.0.
44
+ attr_accessor :opacity
45
+
46
+ # Gets or sets right margin of stamp.
47
+ attr_accessor :right_margin
48
+
49
+ # Sets or gets the rotation of stamp content according values. Note. This property is for set angles which are multiples of 90 degrees (0, 90, 180, 270 degrees). To set arbitrary angle use RotateAngle property. If angle set by ArbitraryAngle is not multiple of 90 then Rotate property returns Rotation.None.
50
+ attr_accessor :rotate
51
+
52
+ # Gets or sets rotate angle of stamp in degrees. This property allows to set arbitrary rotate angle.
53
+ attr_accessor :rotate_angle
54
+
55
+ # Gets or sets top margin of stamp.
56
+ attr_accessor :top_margin
57
+
58
+ # Gets or sets vertical alignment of stamp on page.
59
+ attr_accessor :vertical_alignment
60
+
61
+ # Horizontal stamp coordinate, starting from the left.
62
+ attr_accessor :x_indent
63
+
64
+ # Vertical stamp coordinate, starting from the bottom.
65
+ attr_accessor :y_indent
66
+
67
+ # Zooming factor of the stamp. Allows to scale stamp.
68
+ attr_accessor :zoom
69
+
70
+ # Gets or sets the file name.
71
+ attr_accessor :file_name
72
+
73
+ # Gets or sets the index of the page.
74
+ attr_accessor :page_index
75
+
76
+
77
+ # Attribute mapping from ruby-style variable name to JSON key.
78
+ def self.attribute_map
79
+ {
80
+ :'links' => :'Links',
81
+ :'background' => :'Background',
82
+ :'bottom_margin' => :'BottomMargin',
83
+ :'horizontal_alignment' => :'HorizontalAlignment',
84
+ :'left_margin' => :'LeftMargin',
85
+ :'opacity' => :'Opacity',
86
+ :'right_margin' => :'RightMargin',
87
+ :'rotate' => :'Rotate',
88
+ :'rotate_angle' => :'RotateAngle',
89
+ :'top_margin' => :'TopMargin',
90
+ :'vertical_alignment' => :'VerticalAlignment',
91
+ :'x_indent' => :'XIndent',
92
+ :'y_indent' => :'YIndent',
93
+ :'zoom' => :'Zoom',
94
+ :'file_name' => :'FileName',
95
+ :'page_index' => :'PageIndex'
96
+ }
97
+ end
98
+
99
+ # Attribute type mapping.
100
+ def self.swagger_types
101
+ {
102
+ :'links' => :'Array<Link>',
103
+ :'background' => :'BOOLEAN',
104
+ :'bottom_margin' => :'Float',
105
+ :'horizontal_alignment' => :'HorizontalAlignment',
106
+ :'left_margin' => :'Float',
107
+ :'opacity' => :'Float',
108
+ :'right_margin' => :'Float',
109
+ :'rotate' => :'Rotation',
110
+ :'rotate_angle' => :'Float',
111
+ :'top_margin' => :'Float',
112
+ :'vertical_alignment' => :'VerticalAlignment',
113
+ :'x_indent' => :'Float',
114
+ :'y_indent' => :'Float',
115
+ :'zoom' => :'Float',
116
+ :'file_name' => :'String',
117
+ :'page_index' => :'Integer'
118
+ }
119
+ end
120
+
121
+ # Initializes the object
122
+ # @param [Hash] attributes Model attributes in the form of hash
123
+ def initialize(attributes = {})
124
+ return unless attributes.is_a?(Hash)
125
+
126
+ # convert string to symbol for hash key
127
+ attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
128
+
129
+ if attributes.has_key?(:'Links')
130
+ if (value = attributes[:'Links']).is_a?(Array)
131
+ self.links = value
132
+ end
133
+ end
134
+
135
+ if attributes.has_key?(:'Background')
136
+ self.background = attributes[:'Background']
137
+ end
138
+
139
+ if attributes.has_key?(:'BottomMargin')
140
+ self.bottom_margin = attributes[:'BottomMargin']
141
+ end
142
+
143
+ if attributes.has_key?(:'HorizontalAlignment')
144
+ self.horizontal_alignment = attributes[:'HorizontalAlignment']
145
+ end
146
+
147
+ if attributes.has_key?(:'LeftMargin')
148
+ self.left_margin = attributes[:'LeftMargin']
149
+ end
150
+
151
+ if attributes.has_key?(:'Opacity')
152
+ self.opacity = attributes[:'Opacity']
153
+ end
154
+
155
+ if attributes.has_key?(:'RightMargin')
156
+ self.right_margin = attributes[:'RightMargin']
157
+ end
158
+
159
+ if attributes.has_key?(:'Rotate')
160
+ self.rotate = attributes[:'Rotate']
161
+ end
162
+
163
+ if attributes.has_key?(:'RotateAngle')
164
+ self.rotate_angle = attributes[:'RotateAngle']
165
+ end
166
+
167
+ if attributes.has_key?(:'TopMargin')
168
+ self.top_margin = attributes[:'TopMargin']
169
+ end
170
+
171
+ if attributes.has_key?(:'VerticalAlignment')
172
+ self.vertical_alignment = attributes[:'VerticalAlignment']
173
+ end
174
+
175
+ if attributes.has_key?(:'XIndent')
176
+ self.x_indent = attributes[:'XIndent']
177
+ end
178
+
179
+ if attributes.has_key?(:'YIndent')
180
+ self.y_indent = attributes[:'YIndent']
181
+ end
182
+
183
+ if attributes.has_key?(:'Zoom')
184
+ self.zoom = attributes[:'Zoom']
185
+ end
186
+
187
+ if attributes.has_key?(:'FileName')
188
+ self.file_name = attributes[:'FileName']
189
+ end
190
+
191
+ if attributes.has_key?(:'PageIndex')
192
+ self.page_index = attributes[:'PageIndex']
193
+ end
194
+
195
+ end
196
+
197
+ # Show invalid properties with the reasons. Usually used together with valid?
198
+ # @return Array for valid properies with the reasons
199
+ def list_invalid_properties
200
+ invalid_properties = Array.new
201
+ return invalid_properties
202
+ end
203
+
204
+ # Check to see if the all the properties in the model are valid
205
+ # @return true if the model is valid
206
+ def valid?
207
+ return true
208
+ end
209
+
210
+ # Checks equality by comparing each attribute.
211
+ # @param [Object] Object to be compared
212
+ def ==(o)
213
+ return true if self.equal?(o)
214
+ self.class == o.class &&
215
+ links == o.links &&
216
+ background == o.background &&
217
+ bottom_margin == o.bottom_margin &&
218
+ horizontal_alignment == o.horizontal_alignment &&
219
+ left_margin == o.left_margin &&
220
+ opacity == o.opacity &&
221
+ right_margin == o.right_margin &&
222
+ rotate == o.rotate &&
223
+ rotate_angle == o.rotate_angle &&
224
+ top_margin == o.top_margin &&
225
+ vertical_alignment == o.vertical_alignment &&
226
+ x_indent == o.x_indent &&
227
+ y_indent == o.y_indent &&
228
+ zoom == o.zoom &&
229
+ file_name == o.file_name &&
230
+ page_index == o.page_index
231
+ end
232
+
233
+ # @see the `==` method
234
+ # @param [Object] Object to be compared
235
+ def eql?(o)
236
+ self == o
237
+ end
238
+
239
+ # Calculates hash code according to all attributes.
240
+ # @return [Fixnum] Hash code
241
+ def hash
242
+ [links, background, bottom_margin, horizontal_alignment, left_margin, opacity, right_margin, rotate, rotate_angle, top_margin, vertical_alignment, x_indent, y_indent, zoom, file_name, page_index].hash
243
+ end
244
+
245
+ # Builds the object from hash
246
+ # @param [Hash] attributes Model attributes in the form of hash
247
+ # @return [Object] Returns the model itself
248
+ def build_from_hash(attributes)
249
+ return nil unless attributes.is_a?(Hash)
250
+ self.class.swagger_types.each_pair do |key, type|
251
+ if type =~ /\AArray<(.*)>/i
252
+ # check to ensure the input is an array given that the the attribute
253
+ # is documented as an array but the input is not
254
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
255
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
256
+ end
257
+ elsif !attributes[self.class.attribute_map[key]].nil?
258
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
259
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
260
+ end
261
+
262
+ self
263
+ end
264
+
265
+ # Deserializes the data based on type
266
+ # @param string type Data type
267
+ # @param string value Value to be deserialized
268
+ # @return [Object] Deserialized data
269
+ def _deserialize(type, value)
270
+ case type.to_sym
271
+ when :DateTime
272
+ format = (value.include? '+') ? '/Date(%Q%z)/' : '/Date(%Q)/'
273
+ Time.strptime(value, format).utc.to_datetime
274
+ when :Date
275
+ format = (value.include? '+') ? '/Date(%Q%z)/' : '/Date(%Q)/'
276
+ Time.strptime(value, format).utc.to_datetime.to_date
277
+ when :String
278
+ value.to_s
279
+ when :Integer
280
+ value.to_i
281
+ when :Float
282
+ value.to_f
283
+ when :BOOLEAN
284
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
285
+ true
286
+ else
287
+ false
288
+ end
289
+ when :Object
290
+ # generic object (usually a Hash), return directly
291
+ value
292
+ when /\AArray<(?<inner_type>.+)>\z/
293
+ inner_type = Regexp.last_match[:inner_type]
294
+ value.map { |v| _deserialize(inner_type, v) }
295
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
296
+ k_type = Regexp.last_match[:k_type]
297
+ v_type = Regexp.last_match[:v_type]
298
+ {}.tap do |hash|
299
+ value.each do |k, v|
300
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
301
+ end
302
+ end
303
+ else # model
304
+ temp_model = AsposePdfCloud.const_get(type).new
305
+ temp_model.build_from_hash(value)
306
+ end
307
+ end
308
+
309
+ # Returns the string representation of the object
310
+ # @return [String] String presentation of the object
311
+ def to_s
312
+ to_hash.to_s
313
+ end
314
+
315
+ # to_body is an alias to to_hash (backward compatibility)
316
+ # @return [Hash] Returns the object in the form of hash
317
+ def to_body
318
+ to_hash
319
+ end
320
+
321
+ # Returns the object in the form of hash
322
+ # @return [Hash] Returns the object in the form of hash
323
+ def to_hash
324
+ hash = {}
325
+ self.class.attribute_map.each_pair do |attr, param|
326
+ value = self.send(attr)
327
+ next if value.nil?
328
+ hash[param] = _to_hash(value)
329
+ end
330
+ hash
331
+ end
332
+
333
+ # Outputs non-array value in the form of hash
334
+ # For object, use to_hash. Otherwise, just return the value
335
+ # @param [Object] value Any valid value
336
+ # @return [Hash] Returns the value in the form of hash
337
+ def _to_hash(value)
338
+ if value.is_a?(Array)
339
+ value.compact.map{ |v| _to_hash(v) }
340
+ elsif value.is_a?(Hash)
341
+ {}.tap do |hash|
342
+ value.each { |k, v| hash[k] = _to_hash(v) }
343
+ end
344
+ elsif value.respond_to? :to_hash
345
+ value.to_hash
346
+ else
347
+ value
348
+ end
349
+ end
350
+
351
+ end
352
+
353
+ end
@@ -0,0 +1,221 @@
1
+ =begin
2
+ --------------------------------------------------------------------------------------------------------------------
3
+ Copyright (c) 2019 Aspose.PDF Cloud
4
+ Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ of this software and associated documentation files (the "Software"), to deal
6
+ in the Software without restriction, including without limitation the rights
7
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ copies of the Software, and to permit persons to whom the Software is
9
+ furnished to do so, subject to the following conditions:
10
+ The above copyright notice and this permission notice shall be included in all
11
+ copies or substantial portions of the Software.
12
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
13
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
14
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
15
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
16
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
17
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
18
+ SOFTWARE.
19
+ --------------------------------------------------------------------------------------------------------------------
20
+ =end
21
+
22
+ require 'date'
23
+ require 'time'
24
+
25
+ module AsposePdfCloud
26
+ # Represents a position object
27
+ class Position
28
+ # Gets the X coordinate of the object
29
+ attr_accessor :x_indent
30
+
31
+ # Gets the Y coordinate of the object
32
+ attr_accessor :y_indent
33
+
34
+
35
+ # Attribute mapping from ruby-style variable name to JSON key.
36
+ def self.attribute_map
37
+ {
38
+ :'x_indent' => :'XIndent',
39
+ :'y_indent' => :'YIndent'
40
+ }
41
+ end
42
+
43
+ # Attribute type mapping.
44
+ def self.swagger_types
45
+ {
46
+ :'x_indent' => :'Float',
47
+ :'y_indent' => :'Float'
48
+ }
49
+ end
50
+
51
+ # Initializes the object
52
+ # @param [Hash] attributes Model attributes in the form of hash
53
+ def initialize(attributes = {})
54
+ return unless attributes.is_a?(Hash)
55
+
56
+ # convert string to symbol for hash key
57
+ attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
58
+
59
+ if attributes.has_key?(:'XIndent')
60
+ self.x_indent = attributes[:'XIndent']
61
+ end
62
+
63
+ if attributes.has_key?(:'YIndent')
64
+ self.y_indent = attributes[:'YIndent']
65
+ end
66
+
67
+ end
68
+
69
+ # Show invalid properties with the reasons. Usually used together with valid?
70
+ # @return Array for valid properies with the reasons
71
+ def list_invalid_properties
72
+ invalid_properties = Array.new
73
+ if @x_indent.nil?
74
+ invalid_properties.push("invalid value for 'x_indent', x_indent cannot be nil.")
75
+ end
76
+
77
+ if @y_indent.nil?
78
+ invalid_properties.push("invalid value for 'y_indent', y_indent cannot be nil.")
79
+ end
80
+
81
+ return invalid_properties
82
+ end
83
+
84
+ # Check to see if the all the properties in the model are valid
85
+ # @return true if the model is valid
86
+ def valid?
87
+ return false if @x_indent.nil?
88
+ return false if @y_indent.nil?
89
+ return true
90
+ end
91
+
92
+ # Checks equality by comparing each attribute.
93
+ # @param [Object] Object to be compared
94
+ def ==(o)
95
+ return true if self.equal?(o)
96
+ self.class == o.class &&
97
+ x_indent == o.x_indent &&
98
+ y_indent == o.y_indent
99
+ end
100
+
101
+ # @see the `==` method
102
+ # @param [Object] Object to be compared
103
+ def eql?(o)
104
+ self == o
105
+ end
106
+
107
+ # Calculates hash code according to all attributes.
108
+ # @return [Fixnum] Hash code
109
+ def hash
110
+ [x_indent, y_indent].hash
111
+ end
112
+
113
+ # Builds the object from hash
114
+ # @param [Hash] attributes Model attributes in the form of hash
115
+ # @return [Object] Returns the model itself
116
+ def build_from_hash(attributes)
117
+ return nil unless attributes.is_a?(Hash)
118
+ self.class.swagger_types.each_pair do |key, type|
119
+ if type =~ /\AArray<(.*)>/i
120
+ # check to ensure the input is an array given that the the attribute
121
+ # is documented as an array but the input is not
122
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
123
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
124
+ end
125
+ elsif !attributes[self.class.attribute_map[key]].nil?
126
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
127
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
128
+ end
129
+
130
+ self
131
+ end
132
+
133
+ # Deserializes the data based on type
134
+ # @param string type Data type
135
+ # @param string value Value to be deserialized
136
+ # @return [Object] Deserialized data
137
+ def _deserialize(type, value)
138
+ case type.to_sym
139
+ when :DateTime
140
+ format = (value.include? '+') ? '/Date(%Q%z)/' : '/Date(%Q)/'
141
+ Time.strptime(value, format).utc.to_datetime
142
+ when :Date
143
+ format = (value.include? '+') ? '/Date(%Q%z)/' : '/Date(%Q)/'
144
+ Time.strptime(value, format).utc.to_datetime.to_date
145
+ when :String
146
+ value.to_s
147
+ when :Integer
148
+ value.to_i
149
+ when :Float
150
+ value.to_f
151
+ when :BOOLEAN
152
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
153
+ true
154
+ else
155
+ false
156
+ end
157
+ when :Object
158
+ # generic object (usually a Hash), return directly
159
+ value
160
+ when /\AArray<(?<inner_type>.+)>\z/
161
+ inner_type = Regexp.last_match[:inner_type]
162
+ value.map { |v| _deserialize(inner_type, v) }
163
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
164
+ k_type = Regexp.last_match[:k_type]
165
+ v_type = Regexp.last_match[:v_type]
166
+ {}.tap do |hash|
167
+ value.each do |k, v|
168
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
169
+ end
170
+ end
171
+ else # model
172
+ temp_model = AsposePdfCloud.const_get(type).new
173
+ temp_model.build_from_hash(value)
174
+ end
175
+ end
176
+
177
+ # Returns the string representation of the object
178
+ # @return [String] String presentation of the object
179
+ def to_s
180
+ to_hash.to_s
181
+ end
182
+
183
+ # to_body is an alias to to_hash (backward compatibility)
184
+ # @return [Hash] Returns the object in the form of hash
185
+ def to_body
186
+ to_hash
187
+ end
188
+
189
+ # Returns the object in the form of hash
190
+ # @return [Hash] Returns the object in the form of hash
191
+ def to_hash
192
+ hash = {}
193
+ self.class.attribute_map.each_pair do |attr, param|
194
+ value = self.send(attr)
195
+ next if value.nil?
196
+ hash[param] = _to_hash(value)
197
+ end
198
+ hash
199
+ end
200
+
201
+ # Outputs non-array value in the form of hash
202
+ # For object, use to_hash. Otherwise, just return the value
203
+ # @param [Object] value Any valid value
204
+ # @return [Hash] Returns the value in the form of hash
205
+ def _to_hash(value)
206
+ if value.is_a?(Array)
207
+ value.compact.map{ |v| _to_hash(v) }
208
+ elsif value.is_a?(Hash)
209
+ {}.tap do |hash|
210
+ value.each { |k, v| hash[k] = _to_hash(v) }
211
+ end
212
+ elsif value.respond_to? :to_hash
213
+ value.to_hash
214
+ else
215
+ value
216
+ end
217
+ end
218
+
219
+ end
220
+
221
+ end