Sha256: 58ebf929858dda2750b7a3698eae708dff0b27da9a408083ae972afaf294aa68

Contents?: true

Size: 430 Bytes

Versions: 1

Compression:

Stored size: 430 Bytes

Contents

# frozen_string_literal: true

require_relative '../wrap'
require_relative 'layer'

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
lovely_rufus-1.0.1 lib/lovely_rufus/layers/basic_wrapper.rb