Sha256: 957e96559c506211682d3daf298cec5bb82b75e4a06c8295654a1f344a299c3d

Contents?: true

Size: 478 Bytes

Versions: 1

Compression:

Stored size: 478 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
      pp(tags).join("\n")
    end

    private
    
		def tabwidth
			2
		end
		
    def pp(tags, level = 0)
      tags.map do |tag|
        if tag.respond_to?(:map)
          pp tag, level + 1
        else
          ' ' * (level * tabwidth) + tag.to_s
        end
      end
    end
    
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
csl-1.0.0.pre1 lib/csl/pretty_printer.rb