Class: Soapstone::UI::Components::Box

Inherits:
Object
  • Object
show all
Defined in:
lib/soapstone/ui/components/box.rb

Constant Summary collapse

BLANK_LINE =
""
LINE_BREAK =
"\n"

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(title) ⇒ Box

Returns a new instance of Box.



9
10
11
# File 'lib/soapstone/ui/components/box.rb', line 9

def initialize(title)
  @title = title
end

Class Method Details

.call(title, &block) ⇒ Object



5
6
7
# File 'lib/soapstone/ui/components/box.rb', line 5

def self.call(title, &block)
  new(title).call(&block)
end

Instance Method Details

#call(&block) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/soapstone/ui/components/box.rb', line 13

def call(&block)
  TTY::Box.frame(
    top: 2,
    left: 2,
    width: 80,
    padding: 2,
    border: {type: :thick, bottom: true},
    title: {top_left: " #{title} "}
  ) do
    yield if block_given?
  end
end