Class: SaveToHtml

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

Instance Method Summary collapse

Constructor Details

#initialize(content:, bypass_html: true, name: "index") ⇒ SaveToHtml

Returns a new instance of SaveToHtml.



5
6
7
8
# File 'lib/save_to_html.rb', line 5

def initialize(content:, bypass_html: true, name: "index")
  @content = bypass_html ? Sanitize.fragment(content) : content
  @file_name = name + Time.now.to_s
end

Instance Method Details

#createObject



11
12
13
14
15
# File 'lib/save_to_html.rb', line 11

def create
  File.open(@file_name + ".html", "w") do |f|
    f.write(template)
  end
end