Project

wordwrap

0.0
No commit activity in last 3 years
No release in over 3 years
Wrap words easily e.g. WordWrap.new("Some long line you want to shorten into shorter lines", 32) => returns the string with new line characters on or before the 32 character limit.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies
 Project Readme

Introducing the wordwrap gem

Installation

gem install wordwrap

Usage

require 'wordwrap'

msg = 'This makes the possibility of breaking up a string alot easier than simply writing your own.'
s = WordWrap.new(msg, 30).to_s
puts s

output:

This makes the possibility of
breaking up a string alot
easier than simply writing
your own.
s.split(/\n/).map(&:length)
#=> [29, 25, 26, 9] 


msg = 'Today is Wednesday'
s = WordWrap.new(msg, 30).to_s
a = s.split(/\n/)
#=> ["Today is Wednesday"]

Resources

word_wrap wordwrap wrap slice