Class: LovelyRufus::TextWrapper

Inherits:
Object
  • Object
show all
Defined in:
lib/lovely_rufus/text_wrapper.rb

Constant Summary collapse

QUOTES =
/^([>\/#])(\1| )*/

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(wrap) ⇒ TextWrapper

Returns a new instance of TextWrapper.



16
17
18
# File 'lib/lovely_rufus/text_wrapper.rb', line 16

def initialize(wrap)
  @wrap = wrap
end

Class Method Details

.wrap(text, width: 72) ⇒ Object



12
13
14
# File 'lib/lovely_rufus/text_wrapper.rb', line 12

def self.wrap(text, width: 72)
  new(Wrap[text, width: width]).call
end

Instance Method Details

#callObject



20
21
22
23
24
# File 'lib/lovely_rufus/text_wrapper.rb', line 20

def call
  paras.map do |para|
    chain.call(Wrap[para, width: wrap.width]).text.tr(NBSP, ' ')
  end.join("\n")
end