[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Create a text file with ruby

Marcelo Junior

3/5/2007 2:55:00 AM

How make for create a text file using ruby? And how a make for updated
this text file?

--
Posted via http://www.ruby-....

6 Answers

Harold Hausman

3/5/2007 3:04:00 AM

0

On 3/5/07, Marcelo Junior <marcelo.machado.jr@gmail.com> wrote:
> How make for create a text file using ruby? And how a make for updated
> this text file?
>

# Hello. Consider this code:
File.open( "testfile.txt", "w" ) do |the_file|
the_file.puts "I'm a line in the text file!"
end

# hope that helps,
# -Harold

Harry

3/5/2007 3:12:00 AM

0

On 3/5/07, Marcelo Junior <marcelo.machado.jr@gmail.com> wrote:
> How make for create a text file using ruby? And how a make for updated
> this text file?
>

http://www.rubycentral.com/book/ref_c_file.htm...


Harry

--
http://www.kakueki.com/ruby...
Japanese Ruby List Subjects in English

Marcelo Junior

3/5/2007 4:02:00 PM

0

And how make for get the text of text file?


--
Posted via http://www.ruby-....

Tim Becker

3/5/2007 4:09:00 PM

0

On 3/5/07, Marcelo Junior <marcelo.machado.jr@gmail.com> wrote:
> And how make for get the text of text file?

Also described here:
http://www.rubycentral.com/book/ref_c_file.htm...

Marcelo Junior

3/5/2007 4:13:00 PM

0

Tim Becker wrote:
> On 3/5/07, Marcelo Junior <marcelo.machado.jr@gmail.com> wrote:
>> And how make for get the text of text file?
>
> Also described here:
> http://www.rubycentral.com/book/ref_c_file.htm...

But this not have how get the contet of file. How make this?

--
Posted via http://www.ruby-....

Tim Becker

3/5/2007 4:29:00 PM

0

File inherits from IO, you'll probably want to read that as well
(http://www.rubycentral...ref...). Also, please consider
reading an introductory text on Ruby, because the questions you're
asking are very elementary and covered in any tutorial text.

The Ruby Book (http://www.rubycentral...) that the
documentation we linked to above is from, would be an excellant start.
There's a whole chapter called "Basic Input and Output" that should
contain enough infos about files to get you started.

Take care,
-Tim

On 3/5/07, Marcelo Junior <marcelo.machado.jr@gmail.com> wrote:
> Tim Becker wrote:
> > On 3/5/07, Marcelo Junior <marcelo.machado.jr@gmail.com> wrote:
> >> And how make for get the text of text file?
> >
> > Also described here:
> > http://www.rubycentral...ref_c_file.html#File.new
>
> But this not have how get the contet of file. How make this?
>
> --
> Posted via http://www.ruby-....
>
>