Class: CountLOC::HtmlFileWriter
- Inherits:
-
Object
- Object
- CountLOC::HtmlFileWriter
- Defined in:
- lib/countloc.rb
Overview
Class that writes to a html file
Instance Method Summary collapse
-
#initialize(filename) ⇒ HtmlFileWriter
constructor
A new instance of HtmlFileWriter.
-
#write(data) ⇒ Object
Write the html file, including the data contents (via the to_html method on the data).
Constructor Details
#initialize(filename) ⇒ HtmlFileWriter
Returns a new instance of HtmlFileWriter.
316 317 318 |
# File 'lib/countloc.rb', line 316 def initialize(filename) @filename = filename end |
Instance Method Details
#write(data) ⇒ Object
Write the html file, including the data contents (via the to_html method on the data)
322 323 324 325 326 327 328 |
# File 'lib/countloc.rb', line 322 def write(data) begin File.open(@filename, "w") { |file| file.puts data.to_html } rescue puts "Error: " + $!.to_s end end |