String lenth limit

Hi,

I’ve seen some time ago a function which, given a string like “this is a
very long string” would return , for example limitin it to 10 chars
“this
is a…” , but I can’t remember where… I’ve searched throwth the
apis
of rails and ruby itself and I can’t find it.

Thanks everybody…

Slice? or Split?

On 8/3/06, Matias [email protected] wrote:


Rails mailing list
[email protected]
http://lists.rubyonrails.org/mailman/listinfo/rails


Anime ni naruttebayo!!!

Uchiha Itachi’s Trashcan@ptoys
http://ptoys.proboards40.com/index.cgi?board=showroom&action=display&thread=1108620582

mmm… neither of both…

I’m talking of something like this:

“my very long string again”.funky_function(10) ==> “my very lo…”

I know it’s very easy to implement… I think I’ll end going that way.

Thanks

Uchiha Itachi
escribió:

Slice? or Split?

That’s exactly what I was looking for… thanks a lot.

Ezra Z.
escribió:

On 8/2/06, Ezra Z. [email protected] wrote:

is a…" , but I can’t remember where… I’ve searched throwth

-Ezra


Rails mailing list
[email protected]
http://lists.rubyonrails.org/mailman/listinfo/rails

what object/module is this truncate method defined on?

linux user wrote:

what object/module is this truncate method defined on?

ActionView::Helpers::TextHelper

The appropriate API documentation is here:
http://api.rubyonrails.com/classes/ActionView/Helpers/TextHelper.html#M000505

On Aug 3, 2006, at 9:58 AM, linux user wrote:

very long string" would return , for example limitin it to 10 chars
http://lists.rubyonrails.org/mailman/listinfo/rails

what object/module is this truncate method defined on?

Sorry, its a view helper. So it is available in all views.

-Ezra

On Aug 2, 2006, at 3:00 PM, Matias wrote:

Thanks everybody…


Rails mailing list
[email protected]
http://lists.rubyonrails.org/mailman/listinfo/rails

str = “This is a long string This is a long string This is a long
string This is a long string This is a long string”

truncate str, 20

That will truncate the string to 20 chars and add a ‘…’ to the end.

-Ezra