30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
# File 'lib/json2table.rb', line 30
def self.create_table(hash, options)
html = start_table_tag(options)
if hash.is_a?(Array)
html += "<tr><td>\n"
html += process_array(hash, options)
elsif hash.is_a?(Hash)
hash.each do |key, value|
html += "<tr><th>#{to_human(key)}</th>\n"
html += "<td>"
if value.is_a?(Hash)
html += create_table(value, options)
elsif value.is_a?(Array)
html += process_array(value, options)
else
html += "#{value}</td></tr>\n"
end
end
else
html += "<tr><td>#{hash}</td></tr>\n"
end
html += close_table_tag
return html
end
|