Sha256: 354f48d92a6c3f555ab6e30da0104974885ff1ecb38d5b4a13f4d0eef2ff721b
Contents?: true
Size: 517 Bytes
Versions: 4
Compression:
Stored size: 517 Bytes
Contents
class String # Transform a string into a form that makes for an acceptable title. # # "this is a string".titlecase # #=> "This Is A String" # # @author Eliazar Parra # @author Angelo Lakra (apostrophe fix) def titlecase tr('_', ' '). gsub(/\s+/, ' '). gsub(/\b\w/){ $`[-1,1] == "'" ? $& : $&.upcase } end # Transform a string into a sentence like form. # # "This Is A String".briefcase # #=> "This is a string" # def briefcase titlecase.capitalize end end
Version data entries
4 entries across 4 versions & 2 rubygems