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."
word_arry = words.split(" ")
count=0
line_text="<="
word_arry.each {|word|
count+=word.length
if count > 40
count=0
line_text+="=>\n<="+word+" "
else
#puts count.to_s
end_txt = (count > 38) ? word : word+" "
line_text+=end_txt
end
}
line_text+="=>"
puts line_text
On Wed, May 27, 2009 at 4:01 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
> --
> Posted via http://www.ruby-forum.com/.
>
> >
>
--
With regards,
Arunkumar B.
9789980534.
http://thinkingrails.blogspot.com
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---