class Crayon::Box

Defined in:

crayon/box.cr

Constant Summary

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

Instance Method Summary

Constructor Detail

def self.new(content : String | Array(String)) #

Create the box

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

[View source]

Instance Method Detail

def render : String #

Return the rendered box as a string


[View source]
def set_border_color(color : Color) : self #

Set the border color


[View source]
def set_border_style(style : Style) : self #

Set the border style


[View source]
def 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


[View source]
def 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


[View source]
def 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!│
# └──────────────────────┘

[View source]