module CSL::PrettyPrinter

Public Instance Methods

pretty_print() click to toggle source
# File lib/csl/pretty_printer.rb, line 12
def pretty_print
  preamble << tags.map { |t| pp t }.join("\n")
end
tags() click to toggle source
# File lib/csl/pretty_printer.rb, line 4
def tags
  raise 'not implemened by base class'
end
to_xml() click to toggle source
# File lib/csl/pretty_printer.rb, line 8
def to_xml
  tags.flatten.join
end

Private Instance Methods

pp(tag, level = 0) click to toggle source
# File lib/csl/pretty_printer.rb, line 26
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
preamble() click to toggle source
# File lib/csl/pretty_printer.rb, line 22
def preamble
  ''
end
tabwidth() click to toggle source
# File lib/csl/pretty_printer.rb, line 18
def tabwidth
  2
end