Class: Spoom::FileTree::Printer
- Defined in:
- lib/spoom/file_tree.rb
Overview
An internal class used to print a FileTree
See ‘FileTree#print`
Instance Method Summary collapse
-
#initialize(strictnesses, out: $stdout, colors: true) ⇒ Printer
constructor
: (Hash[FileTree::Node, String?] strictnesses, ?out: (IO | StringIO), ?colors: bool) -> void.
-
#visit_node(node) ⇒ Object
: (FileTree::Node node) -> void.
Methods inherited from Visitor
Constructor Details
#initialize(strictnesses, out: $stdout, colors: true) ⇒ Printer
: (Hash[FileTree::Node, String?] strictnesses, ?out: (IO | StringIO), ?colors: bool) -> void
206 207 208 209 210 211 |
# File 'lib/spoom/file_tree.rb', line 206 def initialize(strictnesses, out: $stdout, colors: true) super() @strictnesses = strictnesses @colors = colors @printer = T.let(Spoom::Printer.new(out: out, colors: colors), Spoom::Printer) end |
Instance Method Details
#visit_node(node) ⇒ Object
: (FileTree::Node node) -> void
215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 |
# File 'lib/spoom/file_tree.rb', line 215 def visit_node(node) @printer.printt if node.children.empty? strictness = @strictnesses[node] if @colors @printer.print_colored(node.name, strictness_color(strictness)) elsif strictness @printer.print("#{node.name} (#{strictness})") else @printer.print(node.name.to_s) end @printer.print("\n") else @printer.print_colored(node.name, Color::BLUE) @printer.print("/") @printer.printn @printer.indent super @printer.dedent end end |