# Urgent help please!

**URL:** <https://www.ruby-forum.com/t/urgent-help-please/168923>\
**Category:** Rails\
**Created:** [May 27, 2009, 12:31pm UTC](https://www.ruby-forum.com/t/urgent-help-please/168923 "2009-05-27T12:31:37Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![dharshannew](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/5fc32e/32.png) [@dharshannew](https://www.ruby-forum.com/u/dharshannew)\
**Post date:** [May 27, 2009, 12:31pm UTC](https://www.ruby-forum.com/t/urgent-help-please/168923/1 "2009-05-27T12:31:37Z")

</div>

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 + “”

end

thanks

---

<div class="post-metadata">

**Author:** ![dharshannew](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/5fc32e/32.png) [@dharshannew](https://www.ruby-forum.com/u/dharshannew)\
**Post date:** [May 27, 2009, 12:49pm UTC](https://www.ruby-forum.com/t/urgent-help-please/168923/2 "2009-05-27T12:49:49Z")

</div>

On Wed, May 27, 2009 at 12:31 PM, Ruby O.  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> to parents, teachers, and kids, is to connect earning and skill
> 
> @counter=“”  
> text.each do |ts|
> 
> @counter += ts + “  
> ”
> 
> end
> 
> thanks

words.scan(/.{0,#{line\_length}}\s\*(?:\b)/)

Andrew T.  
[http://ramblingsonrails.com](http://ramblingsonrails.com)

[http://MyMvelope.com](http://MyMvelope.com) - The SIMPLE way to manage your savings

---

<div class="post-metadata">

**Author:** ![dharshannew](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/5fc32e/32.png) [@dharshannew](https://www.ruby-forum.com/u/dharshannew)\
**Post date:** [May 27, 2009, 12:51pm UTC](https://www.ruby-forum.com/t/urgent-help-please/168923/3 "2009-05-27T12:51:01Z")

</div>

On May 27, 11:31 am, Ruby O. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> have this function with whe work cuts the word inbetween which i  
> don’t want want please help.

You don’t necessarily get the most help by posting essentially the  
same thing 4 times. If I were you i’d be working with the array of  
split up words (word\_arry in your code) rather than trying to slice up  
words

Fred

---

<div class="post-metadata">

**Author:** ![dharshannew](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/5fc32e/32.png) [@dharshannew](https://www.ruby-forum.com/u/dharshannew)\
**Post date:** [May 27, 2009, 12:56pm UTC](https://www.ruby-forum.com/t/urgent-help-please/168923/4 "2009-05-27T12:56:53Z")

</div>

On Wed, May 27, 2009 at 12:50 PM, Julian L.  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Sorry to be a pain.
> 
> Could you please send your email again. Please use better English.  
> Use simpler sentences, if you need to.  
> I don’t understand the problem.
> 
> Julian.

Just by the way, this is exactly why test/behaviour driven development  
works so well.  
If you provided a test/spec with your expectations, it makes it much  
easier for  
a) you to solve your own problem,  
b) us to know we’re solving the problem correctly.

Andrew T.  
[http://ramblingsonrails.com](http://ramblingsonrails.com)

[http://MyMvelope.com](http://MyMvelope.com) - The SIMPLE way to manage your savings

---

<div class="post-metadata">

**Author:** ![dharshannew](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/5fc32e/32.png) [@dharshannew](https://www.ruby-forum.com/u/dharshannew)\
**Post date:** [May 27, 2009, 1:01pm UTC](https://www.ruby-forum.com/t/urgent-help-please/168923/5 "2009-05-27T13:01:37Z")

</div>

On 27/05/2009, at 8:55 PM, Andrew T. wrote:

> Just by the way, this is exactly why test/behaviour driven development  
> works so well.  
> If you provided a test/spec with your expectations, it makes it much  
> easier for  
> a) you to solve your own problem,  
> b) us to know we’re solving the problem correctly.
> 
> Andrew T.  
> [http://ramblingsonrails.com](http://ramblingsonrails.com)

I couldn’t agree more.

Julian.

* * *

Learn: [http://sensei.zenunit.com/](http://sensei.zenunit.com/)  
Last updated 20-May-09 (Rails, Basic Unix)  
Blog: [http://random8.zenunit.com/](http://random8.zenunit.com/)  
Twitter: [http://twitter.com/random8r](http://twitter.com/random8r)

---

<div class="post-metadata">

**Author:** ![dharshannew](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/5fc32e/32.png) [@dharshannew](https://www.ruby-forum.com/u/dharshannew)\
**Post date:** [May 27, 2009, 1:10pm UTC](https://www.ruby-forum.com/t/urgent-help-please/168923/6 "2009-05-27T13:10:03Z")

</div>

Julian L. wrote:

> On 27/05/2009, at 8:31 PM, Ruby O. wrote:
> 
> > have this function with whe work cuts the word inbetween which i  
> > don’t want want please help.
> 
> Sorry to be a pain.
> 
> Could you please send your email again. Please use better English.
> 
> Use simpler sentences, if you need to.
> 
> I don’t understand the problem.
> 
> Julian.
> 
> * * *
> 
> Learn: [http://sensei.zenunit.com/](http://sensei.zenunit.com/)  
> Last updated 20-May-09 (Rails, Basic Unix)  
> Blog: [http://random8.zenunit.com/](http://random8.zenunit.com/)  
> Twitter: [http://twitter.com/random8r](http://twitter.com/random8r)

this is the complete code of controller function

def show  
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 + “  
”

end

@counter = @counter.sub(‘\<=’, ‘’)  
@counter = @counter.split(/(\s+)/).reverse.join(‘’)  
@counter = @counter.sub(‘=\>’, ‘’)  
@counter = @counter.split(/(\s+)/).reverse.join(‘’)

abort @counter  
end

this produces the output

Kid games need to be both fun and educat =\>  
\<= ional. Aimed at ages pre-K through middl =\>  
\<= e school, safe environment to discover t =\>  
\<= heir abilities and learn new skills with =\>  
\<= interactive and fun computer games. Our =\>  
\<= games build skills in math, logic, memo =\>  
\<= ry, vocabulary, alphabet, spelling, geog =\>  
\<= raphy, computer skills, color identifica =\>  
\<= tion, shape identification and other var =\>  
\<= ious problem solving. Our commitment to =\>  
\<= parents, teachers, and kids, is to conne =\>  
\<= ct earning and skill building with a sen =\>  
\<= se of challenge, fun, and self esteem.

you can see the words are being cut inbetween,iwant rather they do not  
come in the line of if they come should come as complete word.

Thanks and regards

---

<div class="post-metadata">

**Author:** ![dharshannew](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/5fc32e/32.png) [@dharshannew](https://www.ruby-forum.com/u/dharshannew)\
**Post date:** [May 27, 2009, 1:52pm UTC](https://www.ruby-forum.com/t/urgent-help-please/168923/7 "2009-05-27T13:52:43Z")

</div>

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 O.  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)wrote:

> to parents, teachers, and kids, is to connect earning and skill
> 
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).
> 
> >

–  
With regards,  
Arunkumar B.  
9789980534.  
[http://thinkingrails.blogspot.com](http://thinkingrails.blogspot.com)

---

<div class="post-metadata">

**Author:** ![dharshannew](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/5fc32e/32.png) [@dharshannew](https://www.ruby-forum.com/u/dharshannew)\
**Post date:** [May 27, 2009, 4:56pm UTC](https://www.ruby-forum.com/t/urgent-help-please/168923/8 "2009-05-27T16:56:50Z")

</div>

following is the method which trims the string which passes as an  
argument and trims if it’s length is greater than collength.

def trimstring(string, collength)  
if(string.length\>collength)  
@str = “”  
col = 0  
@lines = 0…(string.length/collength)  
for @line in @lines  
@str += string[col,collength] + “  
”  
col = col+collength  
end  
return @str  
else  
return string  
end  
end

---

<div class="post-metadata">

**Author:** ![dharshannew](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/5fc32e/32.png) [@dharshannew](https://www.ruby-forum.com/u/dharshannew)\
**Post date:** [May 27, 2009, 12:51pm UTC](https://www.ruby-forum.com/t/urgent-help-please/168923/9 "2009-05-27T12:51:36Z")

</div>

On 27/05/2009, at 8:31 PM, Ruby O. wrote:

> have this function with whe work cuts the word inbetween which i  
> don’t want want please help.

Sorry to be a pain.

Could you please send your email again. Please use better English.

Use simpler sentences, if you need to.

I don’t understand the problem.

Julian.

* * *

Learn: [http://sensei.zenunit.com/](http://sensei.zenunit.com/)  
Last updated 20-May-09 (Rails, Basic Unix)  
Blog: [http://random8.zenunit.com/](http://random8.zenunit.com/)  
Twitter: [http://twitter.com/random8r](http://twitter.com/random8r)
