Class: Charming::Markdown::TextWrapper
- Inherits:
-
Object
- Object
- Charming::Markdown::TextWrapper
- Defined in:
- lib/charming/presentation/markdown/text_wrapper.rb
Overview
TextWrapper wraps Markdown text blocks to a configured terminal width.
Instance Method Summary collapse
-
#initialize(width:) ⇒ TextWrapper
constructor
A new instance of TextWrapper.
- #wrap(value) ⇒ Object
Constructor Details
#initialize(width:) ⇒ TextWrapper
Returns a new instance of TextWrapper.
7 8 9 |
# File 'lib/charming/presentation/markdown/text_wrapper.rb', line 7 def initialize(width:) @width = width end |
Instance Method Details
#wrap(value) ⇒ Object
11 12 13 14 15 |
# File 'lib/charming/presentation/markdown/text_wrapper.rb', line 11 def wrap(value) return value unless width value.to_s.lines(chomp: true).map { |line| wrap_line(line) }.join("\n") end |