2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
# File 'lib/nation/templates/html_file.rb', line 2
def self.convert_html_file(json_object)
path = "./nation_files/html"
file_name = "#{json_object[:name]}_info_#{Time.now.strftime("%d%m%Y%H%M")}"
html = File.new("#{path}/#{file_name}.html", "w+")
html.puts "<!DOCTYPE html>"
html.puts "<html>"
html.puts "<head>"
html.puts "<title>#{file_name}</title>"
html.puts "</head>"
html.puts "<body>"
json_object.each do |k, v|
if k == "name"
html.puts "<h1>#{v.upcase}</h1"
else
html.puts "<div><h3>#{k}</h3> <p>#{v}</p></div>"
end
end
html.puts "</body>"
html.puts "</html>"
html.close()
end
|