Class: TreeStand::Utils::Printer
- Inherits:
-
Object
- Object
- TreeStand::Utils::Printer
- Extended by:
- T::Sig
- Defined in:
- lib/tree_stand/utils/printer.rb
Overview
Used to pretty-print the node.
Instance Method Summary collapse
Constructor Details
#initialize(ralign:) ⇒ void
21 22 23 |
# File 'lib/tree_stand/utils/printer.rb', line 21 def initialize(ralign:) @ralign = ralign end |
Instance Method Details
#print(node, io: StringIO.new) ⇒ IO, ...
27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/tree_stand/utils/printer.rb', line 27 def print(node, io: StringIO.new) lines = pretty_output_lines(node) lines.each do |line| if line.text.empty? io << line.sexpr << "\n" next end io << "#{line.sexpr}#{" " * (@ralign - line.sexpr.size)}| #{line.text}\n" end io end |