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 <matiassurdi@gmail.com> wrote:> > 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.. > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > 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 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060802/fd985a15/attachment.html
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? > > On 8/3/06, Matias <matiassurdi@gmail.com> > wrote: >> >> 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.. >> >> _______________________________________________ >> Rails mailing list >> Rails@lists.rubyonrails.org >> http://lists.rubyonrails.org/mailman/listinfo/rails >> > > >
On Aug 2, 2006, at 3:00 PM, Matias wrote:> 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.. > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/railsstr = "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
That''s exactly what I was looking for.... thanks a lot. Ezra Zygmuntowicz escribi?:> > On Aug 2, 2006, at 3:00 PM, Matias wrote: > >> 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.. >> >> _______________________________________________ >> Rails mailing list >> Rails@lists.rubyonrails.org >> 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
On 8/2/06, Ezra Zygmuntowicz <ezmobius@gmail.com> wrote:> > > On Aug 2, 2006, at 3:00 PM, Matias wrote: > > > 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.. > > > > _______________________________________________ > > Rails mailing list > > Rails@lists.rubyonrails.org > > 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 > > > > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >what object/module is this truncate method defined on? -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060803/0ecda29d/attachment.html
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 -- Posted via http://www.ruby-forum.com/.
On Aug 3, 2006, at 9:58 AM, linux user wrote:> > > On 8/2/06, Ezra Zygmuntowicz <ezmobius@gmail.com> wrote: > > On Aug 2, 2006, at 3:00 PM, Matias wrote: > > > 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.. > > > > _______________________________________________ > > Rails mailing list > > Rails@lists.rubyonrails.org > > 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 > > > > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > 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 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060804/35db701b/attachment-0001.html