On Wed, May 27, 2009 at 12:31 PM, Ruby One
<[email protected]> wrote:
>
> have this function with whe work cuts the word inbetween which i
> don't want want please help.
>
> words = "Kid games need to be both fun and educational. Aimed at ages
> pre-K through middle school, safe environment to discover their
> abilities and learn new skills with interactive and fun computer
> games. Our games build skills in math, logic, memory, vocabulary,
> alphabet, spelling, geography, computer skills, color identification,
> shape identification and other various problem solving. Our commitment
> to parents, teachers, and kids, is to connect earning and skill
> building with a sense of challenge, fun, and self esteem."
>
> line_length = 40
>
> word_arry = words.split(" ")
>
> text = (0..(words.length / line_length)).inject([]) {|v,num| start =
> num * line_length; v << %Q{<= #{words[(start)...(start +
> line_length)]} =>}}
> text.join("\n")
>
> @counter=""
> text.each do |ts|
>
> @counter += ts + "</br>"
>
> end
>
>
> thanks
words.scan(/.{0,#{line_length}}\s*(?:\b)/)
Andrew Timberlake
http://ramblingsonrails.com
http://MyMvelope.com - The SIMPLE way to manage your savings
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---