Sha256: 9b2b49913e82efb6ca7e244495ff0e5f1a74ce644183fd1b6de592afbc9dd4ff

Contents?: true

Size: 352 Bytes

Versions: 4

Compression:

Stored size: 352 Bytes

Contents

require_relative '../wrap'
require_relative 'layer'

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

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
lovely_rufus-1.0.0 lib/lovely_rufus/layers/basic_wrapper.rb
lovely_rufus-0.3.2 lib/lovely_rufus/layers/basic_wrapper.rb
lovely_rufus-0.3.1 lib/lovely_rufus/layers/basic_wrapper.rb
lovely_rufus-0.3.0 lib/lovely_rufus/layers/basic_wrapper.rb