Class: HTMLCreator

Inherits:
Object
  • Object
show all
Defined in:
lib/html_creator.rb

Instance Method Summary collapse

Instance Method Details

#html_create(content, bypass_html, file_name = 'index.html') ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/html_creator.rb', line 4

def html_create(content, bypass_html, file_name = 'index.html')
  content = Sanitize.fragment(content) unless bypass_html
  content = content unless bypass_html == false

  f = File.open(file_name, "w+")
  f.puts "<!DOCTYPE html>"
  f.puts "<html lang=\"uk\">"
  f.puts "  <head>"
  f.puts "    <meta charset='utf-8'>"
  f.puts "    <title>Tamagochi</title>"
  f.puts "  </head>"
  f.puts "  <body>"
  f.puts "    <script>"
  f.puts "    </script>"
  f.puts "    #{content}"
  f.puts "  </body>"
  f.puts "</html>"
  f.close
end