Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Ticket #6335 (closed enhancement: wontfix)

Opened 2 years ago

Last modified 2 years ago

[PATCH] new string methods (capitalize, squeeze, stripLineBreaks)

Reported by: Tobie Assigned to: sam
Priority: normal Milestone: 1.x
Component: Prototype Version:
Severity: normal Keywords: string squeeze prototype linebreaks capitalize
Cc:

Description

Three new string methods I've been using:

  • capitalize method which is pretty self-explanatory,
  • stripLineBreaks method... which replaces line breaks by " ", and
  • squeeze method which acts exactly like ruby's squeeze method and enables the following:
'hello     world".squeeze(' ')                    // -> 'hello world'
'helloooooooo     world...!!!!!!!".squeeze('! o') // -> 'hello world...!'

etc.

unit tests are included.

Attachments

string.diff (1.1 kB) - added by Tobie on 10/17/06 03:50:06.
updated js (corrected issue with Opera)
string.html.diff (2.5 kB) - added by Tobie on 10/17/06 03:50:32.
tests

Change History

10/03/06 06:30:35 changed by Tobie

10/17/06 03:50:06 changed by Tobie

  • attachment string.diff added.

updated js (corrected issue with Opera)

10/17/06 03:50:32 changed by Tobie

  • attachment string.html.diff added.

tests

02/24/07 10:02:46 changed by Tobie

  • status changed from new to closed.
  • resolution set to wontfix.

Closed as wontfix.

String#capitalize() has already been included, String#stripLineBreaks() is an ugly name around a very simple regex... the only one that could be worth keeping is String#squeeze() but I'm not sure if there's much demand for it really.

Might post a new patch for it later on.