Class: Prompts::Paragraph

Inherits:
Object
  • Object
show all
Includes:
TextUtils
Defined in:
lib/prompts/paragraph.rb

Constant Summary collapse

LINE_PADDING =
3

Constants included from TextUtils

TextUtils::ANSI_REGEX

Instance Method Summary collapse

Methods included from TextUtils

#format_line, #strip_ansi, #wrap_text

Constructor Details

#initialize(text, width: 60) ⇒ Paragraph

Returns a new instance of Paragraph.



9
10
11
12
13
# File 'lib/prompts/paragraph.rb', line 9

def initialize(text, width: 60)
  @text = text
  @width = width - (LINE_PADDING + 1)
  @line_padding = SPACE * LINE_PADDING
end

Instance Method Details

#linesObject



15
16
17
# File 'lib/prompts/paragraph.rb', line 15

def lines
  wrap_text(@text, width: @width, line_prefix: @line_padding, alignment: :none)
end