Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > Non-newline gets

Reply
Thread Tools

Non-newline gets

 
 
Michael Boutros
Guest
Posts: n/a
 
      12-21-2008
Hello,

I'm writing a CLI and I want to get some additional information after I
first run the script, namely the username. Take a look.

-- code
puts "Welcome. Enter username: "
username = gets.strip
-- /code

That works fine, but the issue is that it takes the username on a new
line, like so:

$ ruby script.rb
Welcome. Enter username:
michaelboutros

How can I make it so that the username can be entered on the same line?

Thanks,
Michael Boutros
--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
 
 
 
Yaser Sulaiman
Guest
Posts: n/a
 
      12-21-2008
[Note: parts of this message were removed to make it a legal post.]

Don't use puts, use print instead.
print "Welcome. Enter username: "

Regards,
Yaser Sulaiman

On Sun, Dec 21, 2008 at 9:58 AM, Michael Boutros <(E-Mail Removed)>wrote:

> Hello,
>
> I'm writing a CLI and I want to get some additional information after I
> first run the script, namely the username. Take a look.
>
> -- code
> puts "Welcome. Enter username: "
> username = gets.strip
> -- /code
>
> That works fine, but the issue is that it takes the username on a new
> line, like so:
>
> $ ruby script.rb
> Welcome. Enter username:
> michaelboutros
>
> How can I make it so that the username can be entered on the same line?
>
> Thanks,
> Michael Boutros
> --
> Posted via http://www.ruby-forum.com/.
>
>


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Return of gets gets John Joyce Ruby 0 04-23-2007 01:38 PM
gets gets John Joyce Ruby 2 03-26-2007 04:00 PM
XMLHttpRequest gets data to display in element but data gets appended not replaces previous! libsfan01 Javascript 5 12-20-2006 06:25 AM
Not only the selected HREF gets surrounded, but the whole row gets surrounded Stefan Mueller HTML 5 07-10-2006 11:53 AM
Next-gen Windows finally gets a name Silverstrand Software 34 09-12-2005 02:57 PM



Advertisments