Sha256: cf88ec5e3781647d36715b4527a7e9f1279f4e88e4a64227c2a3dbb3c34dcb7c

Contents?: true

Size: 451 Bytes

Versions: 12

Compression:

Stored size: 451 Bytes

Contents

# Some mixed in functionality for String
class String
  
  # Wrap a string to lines of a specified width. All existing newlines
  # are not guaranteed to be preserved
  def wrap(width)
    s = gsub(/\s+/, ' ').strip

    if s.length > width
      s[0...width] + '\n' + s[width..-1].wrap(width)
    else
      s
    end

  end
  
  # Indent each line of a string by n spaces
  def indent(n)
    indent = ' ' * n
    gsub '\n', "\n#{indent}"
  end

end

Version data entries

12 entries across 12 versions & 2 rubygems

Version Path
flazz-bagit-0.0.1 lib/bagit/string.rb
flazz-bagit-0.0.2 lib/bagit/string.rb
bagit-0.3.2 lib/bagit/string.rb
bagit-0.3.2.pre lib/bagit/string.rb
bagit-0.3.1 lib/bagit/string.rb
bagit-0.3.0 lib/bagit/string.rb
bagit-0.3.0.pre lib/bagit/string.rb
bagit-0.2.0 lib/bagit/string.rb
bagit-0.1.0 lib/bagit/string.rb
bagit-0.0.4 lib/bagit/string.rb
bagit-0.0.3 lib/bagit/string.rb
bagit-0.0.2 lib/bagit/string.rb