class

Crayon::Box

Inherits Reference < Object

Constants

STYLES = [{:bottom_left => "", :bottom_right => "", :horizontal => "", :top_left => "", :top_right => "", :vertical => ""}, {:bottom_left => '└', :bottom_right => '┘', :horizontal => '─', :top_left => '┌', :top_right => '┐', :vertical => '│'}, {:bottom_left => '╚', :bottom_right => '╝', :horizontal => '═', :top_left => '╔', :top_right => '╗', :vertical => '║'}, {:bottom_left => '╰', :bottom_right => '╯', :horizontal => '─', :top_left => '╭', :top_right => '╮', :vertical => '│'}, {:bottom_left => '╙', :bottom_right => '╜', :horizontal => '─', :top_left => '╓', :top_right => '╖', :vertical => '║'}, {:bottom_left => '╘', :bottom_right => '╛', :horizontal => '═', :top_left => '╒', :top_right => '╕', :vertical => '│'}, {:bottom_left => '+', :bottom_right => '+', :horizontal => '-', :top_left => '+', :top_right => '+', :vertical => '|'}]

Constructors

new(content : String | Array(String))

Create the box

box = Crayon::Box.new("Rainbows!")
puts box.render
# ┌─────────┐
# │Rainbows!│
# └─────────┘
Source

Instance methods

render

Return the rendered box as a string

Source
set_border_color(color : Color) : self

Set the border color

Source
set_border_style(style : Style) : self

Set the border style

Source
set_margin(x : Int32, y : Int32) : self

Set the external margin of the box

x is the number of empty lines above and below y is the number of spaces to the left and right

Source
set_padding(x : Int32, y : Int32) : self

Set the internal padding of the box

x is the number of empty lines above and below y is the number of spaces to the left and right

Source
set_title(title : String) : self

Set the title of the box

box = Crayon::Box.new("I believe in unicorns!")
box.set_title("Title")
puts box.render
# ┌ Title ───────────────┐
# │I believe in unicorns!│
# └──────────────────────┘
Source

Nested types