Sha256: dec0e1be1b8da8e4f377755468835fd5afc5c58e86cc34a2c27e43f3f5b0d968

Contents?: true

Size: 394 Bytes

Versions: 1

Compression:

Stored size: 394 Bytes

Contents

module LovelyRufus class BasicWrapper < Layer
  def call wrap
    @wrap   = wrap
    wrapped = chopped.gsub(/(.{1,#{wrap.width}})( |$\n?)/, "\\1\n")
    next_layer.call Wrap[wrapped, width: wrap.width]
  end

  attr_reader :wrap
  private     :wrap

  private

  def chopped
    words = wrap.text.split
    words.map { |word| word.gsub(/(.{1,#{wrap.width}})/, '\\1 ') }.join.chop
  end
end end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
lovely_rufus-0.1.0 lib/lovely_rufus/basic_wrapper.rb