Module: Asciidoctor::Writer

Included in:
VoidWriter
Defined in:
lib/asciidoctor/writer.rb

Overview

control how the output is written to disk.

Instance Method Summary collapse

Instance Method Details

#write(output, target) ⇒ void

This method returns an undefined value.

Writes the output to the specified target file name or stream.

Parameters:

  • output

    The output String to write

  • target

    The String file name or stream object to which the output should be written.



12
13
14
15
16
17
18
19
20
21
# File 'lib/asciidoctor/writer.rb', line 12

def write output, target
  if target.respond_to? :write
    # ensure there's a trailing newline to be nice to terminals
    target.write output.chomp + LF
  else
    # QUESTION shouldn't we ensure a trailing newline here too?
    ::File.write target, output, mode: FILE_WRITE_MODE
  end
  nil
end