Class: Klipbook::ToHtml::HtmlPrinter
- Inherits:
-
Object
- Object
- Klipbook::ToHtml::HtmlPrinter
- Defined in:
- lib/klipbook/tohtml/html_printer.rb
Instance Method Summary collapse
-
#initialize(message_stream = $stdout) ⇒ HtmlPrinter
constructor
A new instance of HtmlPrinter.
- #print_to_file(book, output_dir, force) ⇒ Object
Constructor Details
#initialize(message_stream = $stdout) ⇒ HtmlPrinter
Returns a new instance of HtmlPrinter.
5 6 7 |
# File 'lib/klipbook/tohtml/html_printer.rb', line 5 def initialize(=$stdout) @message_stream = end |
Instance Method Details
#print_to_file(book, output_dir, force) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/klipbook/tohtml/html_printer.rb', line 9 def print_to_file(book, output_dir, force) filename = filename_for_book(book) filepath = File.join(output_dir, filename) if !force && File.exists?(filepath) @message_stream.puts(Colours.yellow("Skipping ") + filename) return end @message_stream.puts(Colours.green("Writing ") + filename) File.open(filepath, 'w') do |f| f.write generate_html(book) end end |