finnhub_ruby 1.1.13 → 1.1.16

Sign up to get free protection for your applications and to get access to all the features.
Files changed (36) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +2 -2
  3. data/docs/BondCandles.md +22 -0
  4. data/docs/BondProfile.md +58 -0
  5. data/docs/DefaultApi.md +392 -8
  6. data/docs/InsiderSentiments.md +20 -0
  7. data/docs/InsiderSentimentsData.md +26 -0
  8. data/docs/LobbyingData.md +46 -0
  9. data/docs/LobbyingResult.md +20 -0
  10. data/docs/UsaSpending.md +56 -0
  11. data/docs/UsaSpendingResult.md +20 -0
  12. data/docs/VisaApplication.md +2 -2
  13. data/finnhub_ruby-1.1.13.gem +0 -0
  14. data/finnhub_ruby-1.1.14.gem +0 -0
  15. data/finnhub_ruby-1.1.15.gem +0 -0
  16. data/lib/finnhub_ruby/api/default_api.rb +395 -14
  17. data/lib/finnhub_ruby/models/bond_candles.rb +243 -0
  18. data/lib/finnhub_ruby/models/bond_profile.rb +419 -0
  19. data/lib/finnhub_ruby/models/insider_sentiments.rb +231 -0
  20. data/lib/finnhub_ruby/models/insider_sentiments_data.rb +259 -0
  21. data/lib/finnhub_ruby/models/lobbying_data.rb +359 -0
  22. data/lib/finnhub_ruby/models/lobbying_result.rb +231 -0
  23. data/lib/finnhub_ruby/models/usa_spending.rb +409 -0
  24. data/lib/finnhub_ruby/models/usa_spending_result.rb +231 -0
  25. data/lib/finnhub_ruby/models/visa_application.rb +7 -7
  26. data/lib/finnhub_ruby/version.rb +1 -1
  27. data/lib/finnhub_ruby.rb +8 -0
  28. data/spec/models/bond_candles_spec.rb +46 -0
  29. data/spec/models/bond_profile_spec.rb +154 -0
  30. data/spec/models/insider_sentiments_data_spec.rb +58 -0
  31. data/spec/models/insider_sentiments_spec.rb +40 -0
  32. data/spec/models/lobbying_data_spec.rb +118 -0
  33. data/spec/models/lobbying_result_spec.rb +40 -0
  34. data/spec/models/usa_spending_result_spec.rb +40 -0
  35. data/spec/models/usa_spending_spec.rb +148 -0
  36. metadata +37 -2
@@ -0,0 +1,243 @@
1
+ =begin
2
+ #Finnhub API
3
+
4
+ #No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
5
+
6
+ The version of the OpenAPI document: 1.0.0
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 5.2.1
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module FinnhubRuby
17
+ class BondCandles
18
+ # List of close prices for returned candles.
19
+ attr_accessor :c
20
+
21
+ # List of timestamp for returned candles.
22
+ attr_accessor :t
23
+
24
+ # Status of the response. This field can either be ok or no_data.
25
+ attr_accessor :s
26
+
27
+ # Attribute mapping from ruby-style variable name to JSON key.
28
+ def self.attribute_map
29
+ {
30
+ :'c' => :'c',
31
+ :'t' => :'t',
32
+ :'s' => :'s'
33
+ }
34
+ end
35
+
36
+ # Returns all the JSON keys this model knows about
37
+ def self.acceptable_attributes
38
+ attribute_map.values
39
+ end
40
+
41
+ # Attribute type mapping.
42
+ def self.openapi_types
43
+ {
44
+ :'c' => :'Array<Float>',
45
+ :'t' => :'Array<Integer>',
46
+ :'s' => :'String'
47
+ }
48
+ end
49
+
50
+ # List of attributes with nullable: true
51
+ def self.openapi_nullable
52
+ Set.new([
53
+ ])
54
+ end
55
+
56
+ # Initializes the object
57
+ # @param [Hash] attributes Model attributes in the form of hash
58
+ def initialize(attributes = {})
59
+ if (!attributes.is_a?(Hash))
60
+ fail ArgumentError, "The input argument (attributes) must be a hash in `FinnhubRuby::BondCandles` initialize method"
61
+ end
62
+
63
+ # check to see if the attribute exists and convert string to symbol for hash key
64
+ attributes = attributes.each_with_object({}) { |(k, v), h|
65
+ if (!self.class.attribute_map.key?(k.to_sym))
66
+ fail ArgumentError, "`#{k}` is not a valid attribute in `FinnhubRuby::BondCandles`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
67
+ end
68
+ h[k.to_sym] = v
69
+ }
70
+
71
+ if attributes.key?(:'c')
72
+ if (value = attributes[:'c']).is_a?(Array)
73
+ self.c = value
74
+ end
75
+ end
76
+
77
+ if attributes.key?(:'t')
78
+ if (value = attributes[:'t']).is_a?(Array)
79
+ self.t = value
80
+ end
81
+ end
82
+
83
+ if attributes.key?(:'s')
84
+ self.s = attributes[:'s']
85
+ end
86
+ end
87
+
88
+ # Show invalid properties with the reasons. Usually used together with valid?
89
+ # @return Array for valid properties with the reasons
90
+ def list_invalid_properties
91
+ invalid_properties = Array.new
92
+ invalid_properties
93
+ end
94
+
95
+ # Check to see if the all the properties in the model are valid
96
+ # @return true if the model is valid
97
+ def valid?
98
+ true
99
+ end
100
+
101
+ # Checks equality by comparing each attribute.
102
+ # @param [Object] Object to be compared
103
+ def ==(o)
104
+ return true if self.equal?(o)
105
+ self.class == o.class &&
106
+ c == o.c &&
107
+ t == o.t &&
108
+ s == o.s
109
+ end
110
+
111
+ # @see the `==` method
112
+ # @param [Object] Object to be compared
113
+ def eql?(o)
114
+ self == o
115
+ end
116
+
117
+ # Calculates hash code according to all attributes.
118
+ # @return [Integer] Hash code
119
+ def hash
120
+ [c, t, s].hash
121
+ end
122
+
123
+ # Builds the object from hash
124
+ # @param [Hash] attributes Model attributes in the form of hash
125
+ # @return [Object] Returns the model itself
126
+ def self.build_from_hash(attributes)
127
+ new.build_from_hash(attributes)
128
+ end
129
+
130
+ # Builds the object from hash
131
+ # @param [Hash] attributes Model attributes in the form of hash
132
+ # @return [Object] Returns the model itself
133
+ def build_from_hash(attributes)
134
+ return nil unless attributes.is_a?(Hash)
135
+ self.class.openapi_types.each_pair do |key, type|
136
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
137
+ self.send("#{key}=", nil)
138
+ elsif type =~ /\AArray<(.*)>/i
139
+ # check to ensure the input is an array given that the attribute
140
+ # is documented as an array but the input is not
141
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
142
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
143
+ end
144
+ elsif !attributes[self.class.attribute_map[key]].nil?
145
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
146
+ end
147
+ end
148
+
149
+ self
150
+ end
151
+
152
+ # Deserializes the data based on type
153
+ # @param string type Data type
154
+ # @param string value Value to be deserialized
155
+ # @return [Object] Deserialized data
156
+ def _deserialize(type, value)
157
+ case type.to_sym
158
+ when :Time
159
+ Time.parse(value)
160
+ when :Date
161
+ Date.parse(value)
162
+ when :String
163
+ value.to_s
164
+ when :Integer
165
+ value.to_i
166
+ when :Float
167
+ value.to_f
168
+ when :Boolean
169
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
170
+ true
171
+ else
172
+ false
173
+ end
174
+ when :Object
175
+ # generic object (usually a Hash), return directly
176
+ value
177
+ when /\AArray<(?<inner_type>.+)>\z/
178
+ inner_type = Regexp.last_match[:inner_type]
179
+ value.map { |v| _deserialize(inner_type, v) }
180
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
181
+ k_type = Regexp.last_match[:k_type]
182
+ v_type = Regexp.last_match[:v_type]
183
+ {}.tap do |hash|
184
+ value.each do |k, v|
185
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
186
+ end
187
+ end
188
+ else # model
189
+ # models (e.g. Pet) or oneOf
190
+ klass = FinnhubRuby.const_get(type)
191
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
192
+ end
193
+ end
194
+
195
+ # Returns the string representation of the object
196
+ # @return [String] String presentation of the object
197
+ def to_s
198
+ to_hash.to_s
199
+ end
200
+
201
+ # to_body is an alias to to_hash (backward compatibility)
202
+ # @return [Hash] Returns the object in the form of hash
203
+ def to_body
204
+ to_hash
205
+ end
206
+
207
+ # Returns the object in the form of hash
208
+ # @return [Hash] Returns the object in the form of hash
209
+ def to_hash
210
+ hash = {}
211
+ self.class.attribute_map.each_pair do |attr, param|
212
+ value = self.send(attr)
213
+ if value.nil?
214
+ is_nullable = self.class.openapi_nullable.include?(attr)
215
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
216
+ end
217
+
218
+ hash[param] = _to_hash(value)
219
+ end
220
+ hash
221
+ end
222
+
223
+ # Outputs non-array value in the form of hash
224
+ # For object, use to_hash. Otherwise, just return the value
225
+ # @param [Object] value Any valid value
226
+ # @return [Hash] Returns the value in the form of hash
227
+ def _to_hash(value)
228
+ if value.is_a?(Array)
229
+ value.compact.map { |v| _to_hash(v) }
230
+ elsif value.is_a?(Hash)
231
+ {}.tap do |hash|
232
+ value.each { |k, v| hash[k] = _to_hash(v) }
233
+ end
234
+ elsif value.respond_to? :to_hash
235
+ value.to_hash
236
+ else
237
+ value
238
+ end
239
+ end
240
+
241
+ end
242
+
243
+ end
@@ -0,0 +1,419 @@
1
+ =begin
2
+ #Finnhub API
3
+
4
+ #No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
5
+
6
+ The version of the OpenAPI document: 1.0.0
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 5.2.1
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module FinnhubRuby
17
+ class BondProfile
18
+ # ISIN.
19
+ attr_accessor :isin
20
+
21
+ # Cusip.
22
+ attr_accessor :cusip
23
+
24
+ # FIGI.
25
+ attr_accessor :figi
26
+
27
+ # Coupon.
28
+ attr_accessor :coupon
29
+
30
+ # Period.
31
+ attr_accessor :maturity_date
32
+
33
+ # Offering price.
34
+ attr_accessor :offering_price
35
+
36
+ # Issue date.
37
+ attr_accessor :issue_date
38
+
39
+ # Bond type.
40
+ attr_accessor :bond_type
41
+
42
+ # Bond type.
43
+ attr_accessor :debt_type
44
+
45
+ # Industry.
46
+ attr_accessor :industry_group
47
+
48
+ # Sub-Industry.
49
+ attr_accessor :industry_sub_group
50
+
51
+ # Asset.
52
+ attr_accessor :asset
53
+
54
+ # Asset.
55
+ attr_accessor :asset_type
56
+
57
+ # Dated date.
58
+ attr_accessor :dated_date
59
+
60
+ # First coupon date.
61
+ attr_accessor :first_coupon_date
62
+
63
+ # Offering amount.
64
+ attr_accessor :original_offering
65
+
66
+ # Outstanding amount.
67
+ attr_accessor :amount_outstanding
68
+
69
+ # Payment frequency.
70
+ attr_accessor :payment_frequency
71
+
72
+ # Security level.
73
+ attr_accessor :security_level
74
+
75
+ # Callable.
76
+ attr_accessor :callable
77
+
78
+ # Coupon type.
79
+ attr_accessor :coupon_type
80
+
81
+ # Attribute mapping from ruby-style variable name to JSON key.
82
+ def self.attribute_map
83
+ {
84
+ :'isin' => :'isin',
85
+ :'cusip' => :'cusip',
86
+ :'figi' => :'figi',
87
+ :'coupon' => :'coupon',
88
+ :'maturity_date' => :'maturityDate',
89
+ :'offering_price' => :'offeringPrice',
90
+ :'issue_date' => :'issueDate',
91
+ :'bond_type' => :'bondType',
92
+ :'debt_type' => :'debtType',
93
+ :'industry_group' => :'industryGroup',
94
+ :'industry_sub_group' => :'industrySubGroup',
95
+ :'asset' => :'asset',
96
+ :'asset_type' => :'assetType',
97
+ :'dated_date' => :'datedDate',
98
+ :'first_coupon_date' => :'firstCouponDate',
99
+ :'original_offering' => :'originalOffering',
100
+ :'amount_outstanding' => :'amountOutstanding',
101
+ :'payment_frequency' => :'paymentFrequency',
102
+ :'security_level' => :'securityLevel',
103
+ :'callable' => :'callable',
104
+ :'coupon_type' => :'couponType'
105
+ }
106
+ end
107
+
108
+ # Returns all the JSON keys this model knows about
109
+ def self.acceptable_attributes
110
+ attribute_map.values
111
+ end
112
+
113
+ # Attribute type mapping.
114
+ def self.openapi_types
115
+ {
116
+ :'isin' => :'String',
117
+ :'cusip' => :'String',
118
+ :'figi' => :'String',
119
+ :'coupon' => :'Float',
120
+ :'maturity_date' => :'String',
121
+ :'offering_price' => :'Float',
122
+ :'issue_date' => :'String',
123
+ :'bond_type' => :'String',
124
+ :'debt_type' => :'String',
125
+ :'industry_group' => :'String',
126
+ :'industry_sub_group' => :'String',
127
+ :'asset' => :'String',
128
+ :'asset_type' => :'String',
129
+ :'dated_date' => :'String',
130
+ :'first_coupon_date' => :'String',
131
+ :'original_offering' => :'Float',
132
+ :'amount_outstanding' => :'Float',
133
+ :'payment_frequency' => :'String',
134
+ :'security_level' => :'String',
135
+ :'callable' => :'Boolean',
136
+ :'coupon_type' => :'String'
137
+ }
138
+ end
139
+
140
+ # List of attributes with nullable: true
141
+ def self.openapi_nullable
142
+ Set.new([
143
+ ])
144
+ end
145
+
146
+ # Initializes the object
147
+ # @param [Hash] attributes Model attributes in the form of hash
148
+ def initialize(attributes = {})
149
+ if (!attributes.is_a?(Hash))
150
+ fail ArgumentError, "The input argument (attributes) must be a hash in `FinnhubRuby::BondProfile` initialize method"
151
+ end
152
+
153
+ # check to see if the attribute exists and convert string to symbol for hash key
154
+ attributes = attributes.each_with_object({}) { |(k, v), h|
155
+ if (!self.class.attribute_map.key?(k.to_sym))
156
+ fail ArgumentError, "`#{k}` is not a valid attribute in `FinnhubRuby::BondProfile`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
157
+ end
158
+ h[k.to_sym] = v
159
+ }
160
+
161
+ if attributes.key?(:'isin')
162
+ self.isin = attributes[:'isin']
163
+ end
164
+
165
+ if attributes.key?(:'cusip')
166
+ self.cusip = attributes[:'cusip']
167
+ end
168
+
169
+ if attributes.key?(:'figi')
170
+ self.figi = attributes[:'figi']
171
+ end
172
+
173
+ if attributes.key?(:'coupon')
174
+ self.coupon = attributes[:'coupon']
175
+ end
176
+
177
+ if attributes.key?(:'maturity_date')
178
+ self.maturity_date = attributes[:'maturity_date']
179
+ end
180
+
181
+ if attributes.key?(:'offering_price')
182
+ self.offering_price = attributes[:'offering_price']
183
+ end
184
+
185
+ if attributes.key?(:'issue_date')
186
+ self.issue_date = attributes[:'issue_date']
187
+ end
188
+
189
+ if attributes.key?(:'bond_type')
190
+ self.bond_type = attributes[:'bond_type']
191
+ end
192
+
193
+ if attributes.key?(:'debt_type')
194
+ self.debt_type = attributes[:'debt_type']
195
+ end
196
+
197
+ if attributes.key?(:'industry_group')
198
+ self.industry_group = attributes[:'industry_group']
199
+ end
200
+
201
+ if attributes.key?(:'industry_sub_group')
202
+ self.industry_sub_group = attributes[:'industry_sub_group']
203
+ end
204
+
205
+ if attributes.key?(:'asset')
206
+ self.asset = attributes[:'asset']
207
+ end
208
+
209
+ if attributes.key?(:'asset_type')
210
+ self.asset_type = attributes[:'asset_type']
211
+ end
212
+
213
+ if attributes.key?(:'dated_date')
214
+ self.dated_date = attributes[:'dated_date']
215
+ end
216
+
217
+ if attributes.key?(:'first_coupon_date')
218
+ self.first_coupon_date = attributes[:'first_coupon_date']
219
+ end
220
+
221
+ if attributes.key?(:'original_offering')
222
+ self.original_offering = attributes[:'original_offering']
223
+ end
224
+
225
+ if attributes.key?(:'amount_outstanding')
226
+ self.amount_outstanding = attributes[:'amount_outstanding']
227
+ end
228
+
229
+ if attributes.key?(:'payment_frequency')
230
+ self.payment_frequency = attributes[:'payment_frequency']
231
+ end
232
+
233
+ if attributes.key?(:'security_level')
234
+ self.security_level = attributes[:'security_level']
235
+ end
236
+
237
+ if attributes.key?(:'callable')
238
+ self.callable = attributes[:'callable']
239
+ end
240
+
241
+ if attributes.key?(:'coupon_type')
242
+ self.coupon_type = attributes[:'coupon_type']
243
+ end
244
+ end
245
+
246
+ # Show invalid properties with the reasons. Usually used together with valid?
247
+ # @return Array for valid properties with the reasons
248
+ def list_invalid_properties
249
+ invalid_properties = Array.new
250
+ invalid_properties
251
+ end
252
+
253
+ # Check to see if the all the properties in the model are valid
254
+ # @return true if the model is valid
255
+ def valid?
256
+ true
257
+ end
258
+
259
+ # Checks equality by comparing each attribute.
260
+ # @param [Object] Object to be compared
261
+ def ==(o)
262
+ return true if self.equal?(o)
263
+ self.class == o.class &&
264
+ isin == o.isin &&
265
+ cusip == o.cusip &&
266
+ figi == o.figi &&
267
+ coupon == o.coupon &&
268
+ maturity_date == o.maturity_date &&
269
+ offering_price == o.offering_price &&
270
+ issue_date == o.issue_date &&
271
+ bond_type == o.bond_type &&
272
+ debt_type == o.debt_type &&
273
+ industry_group == o.industry_group &&
274
+ industry_sub_group == o.industry_sub_group &&
275
+ asset == o.asset &&
276
+ asset_type == o.asset_type &&
277
+ dated_date == o.dated_date &&
278
+ first_coupon_date == o.first_coupon_date &&
279
+ original_offering == o.original_offering &&
280
+ amount_outstanding == o.amount_outstanding &&
281
+ payment_frequency == o.payment_frequency &&
282
+ security_level == o.security_level &&
283
+ callable == o.callable &&
284
+ coupon_type == o.coupon_type
285
+ end
286
+
287
+ # @see the `==` method
288
+ # @param [Object] Object to be compared
289
+ def eql?(o)
290
+ self == o
291
+ end
292
+
293
+ # Calculates hash code according to all attributes.
294
+ # @return [Integer] Hash code
295
+ def hash
296
+ [isin, cusip, figi, coupon, maturity_date, offering_price, issue_date, bond_type, debt_type, industry_group, industry_sub_group, asset, asset_type, dated_date, first_coupon_date, original_offering, amount_outstanding, payment_frequency, security_level, callable, coupon_type].hash
297
+ end
298
+
299
+ # Builds the object from hash
300
+ # @param [Hash] attributes Model attributes in the form of hash
301
+ # @return [Object] Returns the model itself
302
+ def self.build_from_hash(attributes)
303
+ new.build_from_hash(attributes)
304
+ end
305
+
306
+ # Builds the object from hash
307
+ # @param [Hash] attributes Model attributes in the form of hash
308
+ # @return [Object] Returns the model itself
309
+ def build_from_hash(attributes)
310
+ return nil unless attributes.is_a?(Hash)
311
+ self.class.openapi_types.each_pair do |key, type|
312
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
313
+ self.send("#{key}=", nil)
314
+ elsif type =~ /\AArray<(.*)>/i
315
+ # check to ensure the input is an array given that the attribute
316
+ # is documented as an array but the input is not
317
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
318
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
319
+ end
320
+ elsif !attributes[self.class.attribute_map[key]].nil?
321
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
322
+ end
323
+ end
324
+
325
+ self
326
+ end
327
+
328
+ # Deserializes the data based on type
329
+ # @param string type Data type
330
+ # @param string value Value to be deserialized
331
+ # @return [Object] Deserialized data
332
+ def _deserialize(type, value)
333
+ case type.to_sym
334
+ when :Time
335
+ Time.parse(value)
336
+ when :Date
337
+ Date.parse(value)
338
+ when :String
339
+ value.to_s
340
+ when :Integer
341
+ value.to_i
342
+ when :Float
343
+ value.to_f
344
+ when :Boolean
345
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
346
+ true
347
+ else
348
+ false
349
+ end
350
+ when :Object
351
+ # generic object (usually a Hash), return directly
352
+ value
353
+ when /\AArray<(?<inner_type>.+)>\z/
354
+ inner_type = Regexp.last_match[:inner_type]
355
+ value.map { |v| _deserialize(inner_type, v) }
356
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
357
+ k_type = Regexp.last_match[:k_type]
358
+ v_type = Regexp.last_match[:v_type]
359
+ {}.tap do |hash|
360
+ value.each do |k, v|
361
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
362
+ end
363
+ end
364
+ else # model
365
+ # models (e.g. Pet) or oneOf
366
+ klass = FinnhubRuby.const_get(type)
367
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
368
+ end
369
+ end
370
+
371
+ # Returns the string representation of the object
372
+ # @return [String] String presentation of the object
373
+ def to_s
374
+ to_hash.to_s
375
+ end
376
+
377
+ # to_body is an alias to to_hash (backward compatibility)
378
+ # @return [Hash] Returns the object in the form of hash
379
+ def to_body
380
+ to_hash
381
+ end
382
+
383
+ # Returns the object in the form of hash
384
+ # @return [Hash] Returns the object in the form of hash
385
+ def to_hash
386
+ hash = {}
387
+ self.class.attribute_map.each_pair do |attr, param|
388
+ value = self.send(attr)
389
+ if value.nil?
390
+ is_nullable = self.class.openapi_nullable.include?(attr)
391
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
392
+ end
393
+
394
+ hash[param] = _to_hash(value)
395
+ end
396
+ hash
397
+ end
398
+
399
+ # Outputs non-array value in the form of hash
400
+ # For object, use to_hash. Otherwise, just return the value
401
+ # @param [Object] value Any valid value
402
+ # @return [Hash] Returns the value in the form of hash
403
+ def _to_hash(value)
404
+ if value.is_a?(Array)
405
+ value.compact.map { |v| _to_hash(v) }
406
+ elsif value.is_a?(Hash)
407
+ {}.tap do |hash|
408
+ value.each { |k, v| hash[k] = _to_hash(v) }
409
+ end
410
+ elsif value.respond_to? :to_hash
411
+ value.to_hash
412
+ else
413
+ value
414
+ end
415
+ end
416
+
417
+ end
418
+
419
+ end