Sha256: 92d1d6a8c38ae73ce05cc4677f3e314a8f2cb8ca22dd62035cb2dc6146655eb3

Contents?: true

Size: 525 Bytes

Versions: 24

Compression:

Stored size: 525 Bytes

Contents

module CSL
  module PrettyPrinter
    
    def tags
      raise 'not implemened by base class'
    end
    
    def to_xml
      tags.flatten.join
    end

    def pretty_print
      preamble << tags.map { |t| pp t }.join("\n")
    end

    private
    
    def tabwidth
      2
    end
    
    def preamble
      ''
    end
    
    def pp(tag, level = 0)
      if tag.is_a?(Array)
        tag.map { |t| pp t, level + 1 }.join("\n")
      else
        (' ' * (level * tabwidth)) << tag.to_s
      end
    end
    
  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
csl-2.0.0 lib/csl/pretty_printer.rb
csl-1.6.0 lib/csl/pretty_printer.rb
csl-1.5.2 lib/csl/pretty_printer.rb
csl-1.5.1 lib/csl/pretty_printer.rb
csl-1.5.0 lib/csl/pretty_printer.rb
csl-1.4.5 lib/csl/pretty_printer.rb
csl-1.4.4 lib/csl/pretty_printer.rb
csl-1.4.3 lib/csl/pretty_printer.rb
csl-1.4.2 lib/csl/pretty_printer.rb
csl-1.4.1 lib/csl/pretty_printer.rb
csl-1.4.0 lib/csl/pretty_printer.rb
csl-1.3.2 lib/csl/pretty_printer.rb
csl-1.3.1 lib/csl/pretty_printer.rb
csl-1.3.0 lib/csl/pretty_printer.rb
csl-1.2.3 lib/csl/pretty_printer.rb
csl-1.2.2 lib/csl/pretty_printer.rb
csl-1.2.1 lib/csl/pretty_printer.rb
csl-1.2.0 lib/csl/pretty_printer.rb
csl-1.1.0 lib/csl/pretty_printer.rb
csl-1.0.2 lib/csl/pretty_printer.rb