Sha256: b0dd6c8f2f6a4b58800f618b937ee5755ab99e774d3525cb6df44b5120404feb

Contents?: true

Size: 231 Bytes

Versions: 12

Compression:

Stored size: 231 Bytes

Contents

# frozen_string_literal: true

module Wrap
  module_function

  def wrap(str, width = 80)
    str.lines.map do |line|
      line.size > width ? line.gsub(/(.{1,#{width}})(\s+|$)/, "\\1\n").strip : line
    end.join("\n")
  end
end

Version data entries

12 entries across 12 versions & 2 rubygems

Version Path
dpl-2.0.5.3 lib/dpl/helper/wrap.rb
dpl-2.0.5.3.beta.1 lib/dpl/helper/wrap.rb
dpl-2.0.5.2 lib/dpl/helper/wrap.rb
dpl-2.0.5.2.beta.1 lib/dpl/helper/wrap.rb
dpl-2.0.5.1 lib/dpl/helper/wrap.rb
dpl-2.0.5.beta.2.1 lib/dpl/helper/wrap.rb
dpl-2.0.5.beta.2 lib/dpl/helper/wrap.rb
dpl-2.0.5 lib/dpl/helper/wrap.rb
dpl-2.0.5.beta.1 lib/dpl/helper/wrap.rb
dpl-2.0.5.beta lib/dpl/helper/wrap.rb
travis_dpl_test-2.0.3.beta.4.ror.1 lib/dpl/helper/wrap.rb
travis_dpl_test-2.0.3.beta.4.ror lib/dpl/helper/wrap.rb