class Crayon::Box
- Crayon::Box
- Reference
- Object
Defined in:
crayon/box.crConstant 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
-
.new(content : String | Array(String))
Create the box
Instance Method Summary
-
#render : String
Return the rendered box as a string
-
#set_border_color(color : Color) : self
Set the border color
-
#set_border_style(style : Style) : self
Set the border style
-
#set_margin(x : Int32, y : Int32) : self
Set the external margin of the box
-
#set_padding(x : Int32, y : Int32) : self
Set the internal padding of the box
-
#set_title(title : String) : self
Set the title of the box
Constructor Detail
def self.new(content : String | Array(String))
#
Create the box
box = Crayon::Box.new("Rainbows!")
puts box.render
# ┌─────────┐
# │Rainbows!│
# └─────────┘
Instance Method Detail
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
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
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!│
# └──────────────────────┘