ClearMyBench
Welcome, Guest
Please Login or Register.    Lost Password?
Re:Ruby basics (1 viewing) (1) Guest
Go to bottom Post Reply Favoured: 0
TOPIC: Re:Ruby basics
#4505
ShriNi (User)
Software Techie (PEGA) currently on a Career Break
Platinum Boarder
Posts: 4000
graph
User Offline Click here to see the profile of this user
Gender: Female Location: Secundrabad India Birthdate: 1983-09-29
Re:Ruby basics 3 Years, 11 Months ago Karma: 0  
The gets Statement:

The gets statement can be used to take any input from the user from standard screen called STDIN.
 
Report to moderator   Logged Logged  
  The administrator has disabled public write access.
#4506
ShriNi (User)
Software Techie (PEGA) currently on a Career Break
Platinum Boarder
Posts: 4000
graph
User Offline Click here to see the profile of this user
Gender: Female Location: Secundrabad India Birthdate: 1983-09-29
Re:Ruby basics 3 Years, 11 Months ago Karma: 0  
Let us consider an example

The following code shows you how to use the gets statement.

This code will prompt the user to enter a value, which will be stored in a variable val and finally will be printed on STDOUT.

#!/usr/bin/ruby

puts "Enter a value :"
val = gets
puts val
 
Report to moderator   Logged Logged  
  The administrator has disabled public write access.
#4507
ShriNi (User)
Software Techie (PEGA) currently on a Career Break
Platinum Boarder
Posts: 4000
graph
User Offline Click here to see the profile of this user
Gender: Female Location: Secundrabad India Birthdate: 1983-09-29
Re:Ruby basics 3 Years, 11 Months ago Karma: 0  
The putc Statement:


Unlike the puts statement, which outputs the entire string onto the screen, the putc statement can be used to output one character at a time.
 
Report to moderator   Logged Logged  
  The administrator has disabled public write access.
#4508
ShriNi (User)
Software Techie (PEGA) currently on a Career Break
Platinum Boarder
Posts: 4000
graph
User Offline Click here to see the profile of this user
Gender: Female Location: Secundrabad India Birthdate: 1983-09-29
Re:Ruby basics 3 Years, 11 Months ago Karma: 0  
The print Statement

The print statement is similar to the puts statement.

The only difference is that the puts statement goes to the next line after printing the contents, whereas with the print statement the cursor is positioned on the same line.
 
Report to moderator   Logged Logged  
  The administrator has disabled public write access.
#4509
ShriNi (User)
Software Techie (PEGA) currently on a Career Break
Platinum Boarder
Posts: 4000
graph
User Offline Click here to see the profile of this user
Gender: Female Location: Secundrabad India Birthdate: 1983-09-29
Re:Ruby basics 3 Years, 11 Months ago Karma: 0  
Opening and Closing Files


The File.new Method:

we can create a File object using File.new method for reading, writing, or both, according to the mode string.

Finallywe can use File.close method to close that file.
 
Report to moderator   Logged Logged  
  The administrator has disabled public write access.
#4510
ShriNi (User)
Software Techie (PEGA) currently on a Career Break
Platinum Boarder
Posts: 4000
graph
User Offline Click here to see the profile of this user
Gender: Female Location: Secundrabad India Birthdate: 1983-09-29
Re:Ruby basics 3 Years, 11 Months ago Karma: 0  
The File.open Method

we can use File.open method to create a new file object and assign that file object to a file.
 
Report to moderator   Logged Logged  
  The administrator has disabled public write access.
Go to top Post Reply
get the latest posts directly to your desktop
logo footer   Copyright 2009 - 2013 HotRecruiter.Com - All Rights Reserved