class Eskimo::ASCII::Gutter

Prepend each line with a character or symbol.

Gutter.new(char: '| ') do
  [ "Hello", "\n", "World!" ]
end
# => "| Hello"
#    "| World!"

Attributes

char[R]
spacing[R]

Public Class Methods

new(char:, spacing: 0, &children) click to toggle source
Calls superclass method Eskimo::ASCII::Component::new
# File lib/eskimo/ascii/components/gutter.rb, line 14
def initialize(char:, spacing: 0, &children)
  @char = char
  @spacing = spacing

  super
end

Public Instance Methods

render(**) click to toggle source
Calls superclass method Eskimo::ASCII::Component#render
# File lib/eskimo/ascii/components/gutter.rb, line 21
def render(**)
  spacer = Array.new(spacing, char)

  [
    *spacer,
    super.lines.map { |s| s.prepend(char) }.join,
    *spacer
  ].join("\n")
end