Class: Charming::UI::BorderPainter
- Inherits:
-
Object
- Object
- Charming::UI::BorderPainter
- Defined in:
- lib/charming/presentation/ui/border_painter.rb
Constant Summary collapse
- DEFAULT_SIDES =
%i[top right bottom left].freeze
Instance Method Summary collapse
-
#initialize(border:, sides: nil, foreground: nil, background: nil) ⇒ BorderPainter
constructor
A new instance of BorderPainter.
- #paint(lines, inner_width) ⇒ Object
Constructor Details
#initialize(border:, sides: nil, foreground: nil, background: nil) ⇒ BorderPainter
Returns a new instance of BorderPainter.
8 9 10 11 12 13 |
# File 'lib/charming/presentation/ui/border_painter.rb', line 8 def initialize(border:, sides: nil, foreground: nil, background: nil) @border = border @sides = Array(sides || DEFAULT_SIDES).map(&:to_sym) @foreground = foreground @background = background end |
Instance Method Details
#paint(lines, inner_width) ⇒ Object
15 16 17 18 19 20 |
# File 'lib/charming/presentation/ui/border_painter.rb', line 15 def paint(lines, inner_width) horizontal = @border.horizontal * inner_width body = lines.map { |line| border_line(line, inner_width) } [top_border(horizontal), *body, bottom_border(horizontal)].compact end |