answersLogoWhite

0

How is a file read in ruby?

User Avatar

Anonymous

15y ago
Updated: 8/17/2019

You can use a variable to represent a the file that you are going to read. from there, you can display each line using the statement "line = file.gets)


def sample

file = File.new("wildcat.txt")

while (line = file.gets)

puts "#{line}"

end

file.close

end

User Avatar

Wiki User

15y ago

What else can I help you with?

Related Questions

Is ruby Bella's friend?

Who's Ruby? I've read the whole Twilight Series and I've never heard of Ruby. Have you read the books at all?


How do you read a dump file?

pick up a file from a dustbin and read it,,,,a file in a dustbin is known as dumb file...


On Pokemon ruby it said your saved file is deleted how do you get the file back?

you can't, so your screwed.


What are typical access rights that may be granted or denied to a particular user for a particular file?

Read, write, execute, and functions in software objects.


How do you use cwcheat?

You read the Read Me file.


How do you change a read only file into a read write file?

To change a read only file into a read write file, first find the file to be edited. Then right click the file and click on properties. Next, click the general tab and clear the read only check box. Lastly, click on the OK button.


How do you read a pdf file on mobile?

Upload the pdf file to Google Doc,and read that throught that! Or install some software that can read it!


What is meant by read and write txt in file handling?

read: moving data from file to memory write: moving data from memory to file


Did Ruby Bridges ever get married?

RUBY BRIDGES IS MARRIED TO MALCOM HALL READ "THROUGH MY EYES"


Can a file with a weird extension but with batch file code be read using another batch file?

Nope, the format of a file is a vital part of a successful batch file. Even if a file with an unknown file format contains working batch file code in it, a batch file will still not be able to read it because of its foreign file extension. If you want the batch file to be able to read the foreign file, then you can set it to rename the mutated file to .bat format and then read it for it to work. Example: @Echo off REN File.Foreign File.bat CALL File.bat exit


What is a compatible file?

A compatible file is a file name extension (or format) that a program can read.


How to verify the ntfs and folder permissions?

NTFS File Permission Allows the User To Full Control Change permissions and take ownership, plus perform the actions permitted by all other NTFS file permissions Modify Modify and delete the file plus perform the actions permitted by the Write permission and the Read & Execute permission Read & Execute Run applications plus perform the actions permitted by the Read permission Read Read the file, and view file attributes, ownership, and permissions Write Overwrite the file, change file attributes, and view file ownership and permissions