"Fossies" - the Fresh Open Source Software Archive

Member "asciidoctor-2.0.10/lib/asciidoctor/writer.rb" (1 Jun 2019, 888 Bytes) of package /linux/www/asciidoctor-2.0.10.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Ruby source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 # frozen_string_literal: true
    2 module Asciidoctor
    3 # A module that can be used to mix the {#write} method into a {Converter} implementation to allow the converter to
    4 # control how the output is written to disk.
    5 module Writer
    6   # Public: Writes the output to the specified target file name or stream.
    7   #
    8   # output - The output String to write
    9   # target - The String file name or stream object to which the output should be written.
   10   #
   11   # Returns nothing
   12   def write output, target
   13     if target.respond_to? :write
   14       # ensure there's a trailing newline to be nice to terminals
   15       target.write output.chomp + LF
   16     else
   17       # QUESTION shouldn't we ensure a trailing newline here too?
   18       ::File.write target, output, mode: FILE_WRITE_MODE
   19     end
   20     nil
   21   end
   22 end
   23 
   24 module VoidWriter
   25   include Writer
   26 
   27   # Public: Does not write output
   28   def write output, target; end
   29 end
   30 end