Module: Clack::Box
- Defined in:
- lib/clack/box.rb
Overview
Renders a box with optional title around content Supports alignment, padding, and rounded/square corners
Class Method Summary collapse
Class Method Details
.render(message = "", title: "", content_align: :left, title_align: :left, width: :auto, title_padding: 1, content_padding: 2, rounded: true, format_border: nil, output: $stdout) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/clack/box.rb', line 18 def render( = "", title: "", content_align: :left, title_align: :left, width: :auto, title_padding: 1, content_padding: 2, rounded: true, format_border: nil, output: $stdout ) ctx = build_context(, title, title_padding, content_padding, width, rounded, format_border) output.puts build_top_border(ctx[:display_title], ctx[:inner_width], title_padding, title_align, ctx[:symbols], ctx[:h_symbol]) render_content_lines(output, ctx, content_align, content_padding) output.puts "#{ctx[:symbols][2]}#{ctx[:h_symbol] * ctx[:inner_width]}#{ctx[:symbols][3]}" end |