Skip to content
jrobertsonPublic

About

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.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Latest commit

 

History

5 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 

Repository files navigation

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

About

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.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages