Method: Json2table.process_array
- Defined in:
- lib/json2table.rb
.process_array(arr, options) ⇒ Object
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/json2table.rb', line 58 def self.process_array(arr, ) html = "" if arr[0].is_a?(Hash) # Array of hashes keys = similar_keys?(arr) if keys # if elements of this array are hashes with same keys, # display it as a top-down table html += create_vertical_table_from_array(arr, keys, ) else # non similar keys, create horizontal table arr.each do |h| html += create_table(h, ) end end else # array of a primitive data types eg. [1,2,3] # all values can be displayed in a single column table arr.each do |element| html += "#{element}<br/>\n" end end return html end |