Sha256: 152a75b5276dac028f2e1617309741a182f437e35515df2bbf757083422756ee

Contents?: true

Size: 508 Bytes

Versions: 20

Compression:

Stored size: 508 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

20 entries across 20 versions & 1 rubygems

Version Path
csl-1.0.0.pre21 lib/csl/pretty_printer.rb
csl-1.0.0.pre20 lib/csl/pretty_printer.rb
csl-1.0.0.pre19 lib/csl/pretty_printer.rb
csl-1.0.0.pre18 lib/csl/pretty_printer.rb
csl-1.0.0.pre17 lib/csl/pretty_printer.rb
csl-1.0.0.pre16 lib/csl/pretty_printer.rb
csl-1.0.0.pre15 lib/csl/pretty_printer.rb
csl-1.0.0.pre14 lib/csl/pretty_printer.rb
csl-1.0.0.pre13 lib/csl/pretty_printer.rb
csl-1.0.0.pre12 lib/csl/pretty_printer.rb
csl-1.0.0.pre11 lib/csl/pretty_printer.rb
csl-1.0.0.pre10 lib/csl/pretty_printer.rb
csl-1.0.0.pre9 lib/csl/pretty_printer.rb
csl-1.0.0.pre8 lib/csl/pretty_printer.rb
csl-1.0.0.pre7 lib/csl/pretty_printer.rb
csl-1.0.0.pre6 lib/csl/pretty_printer.rb
csl-1.0.0.pre5 lib/csl/pretty_printer.rb
csl-1.0.0.pre4 lib/csl/pretty_printer.rb
csl-1.0.0.pre3 lib/csl/pretty_printer.rb
csl-1.0.0.pre2 lib/csl/pretty_printer.rb