how do you use marshal.dump in Ruby please?

Thread Solved

Join Date: Mar 2007
Posts: 8
Reputation: Gazco is an unknown quantity at this point 
Solved Threads: 2
Gazco's Avatar
Gazco Gazco is offline Offline
Newbie Poster

how do you use marshal.dump in Ruby please?

 
0
  #1
Apr 22nd, 2007
Hey, I'm learning Ruby and I've just about got it sorted. I have just one (or maybe more) question(s): What is marshal.dump and does it allow you to save data to a file outside of the Ruby program? If not, how do I create saved data (ie. character attributes inside a text-based game)? Thanks for answers!
Reply With Quote Quick reply to this message  
Join Date: Oct 2005
Posts: 523
Reputation: pty is on a distinguished road 
Solved Threads: 37
pty's Avatar
pty pty is offline Offline
Posting Pro

Re: how do you use marshal.dump in Ruby please?

 
0
  #2
Apr 22nd, 2007
Originally Posted by Gazco View Post
Hey, I'm learning Ruby and I've just about got it sorted. I have just one (or maybe more) question(s): What is marshal.dump and does it allow you to save data to a file outside of the Ruby program? If not, how do I create saved data (ie. character attributes inside a text-based game)? Thanks for answers!
For some reason the rubycentral site seems to be down so the original article I'd link to isn't available, however it's in the google cache.
Note to self... pocket cup
Reply With Quote Quick reply to this message  
Join Date: Apr 2007
Posts: 9
Reputation: IndianGuru is an unknown quantity at this point 
Solved Threads: 1
IndianGuru IndianGuru is offline Offline
Newbie Poster

Re: how do you use marshal.dump in Ruby please?

 
0
  #3
Apr 22nd, 2007
Originally Posted by Gazco View Post
Hey, I'm learning Ruby and I've just about got it sorted. I have just one (or maybe more) question(s): What is marshal.dump and does it allow you to save data to a file outside of the Ruby program? If not, how do I create saved data (ie. character attributes inside a text-based game)? Thanks for answers!
You can read this small tutorial here -
http://sitekreator.com/satishtalim/o...alization.html

Hope that helps.
Satish Talim
Learning Ruby
Reply With Quote Quick reply to this message  
Join Date: Mar 2007
Posts: 8
Reputation: Gazco is an unknown quantity at this point 
Solved Threads: 2
Gazco's Avatar
Gazco Gazco is offline Offline
Newbie Poster

Re: how do you use marshal.dump in Ruby please?

 
0
  #4
Apr 23rd, 2007
Thanks, these sites really helped a lot and answered my questions, but the last one also brought up one little one: in the second example the programmer used
  1. File.open('game', 'w+') do |f|
What does the string
  1. 'w+'
do and
  1. |f|
do please? Thanks once again for any help.
Reply With Quote Quick reply to this message  
Join Date: Oct 2005
Posts: 523
Reputation: pty is on a distinguished road 
Solved Threads: 37
pty's Avatar
pty pty is offline Offline
Posting Pro

Re: how do you use marshal.dump in Ruby please?

 
0
  #5
Apr 23rd, 2007
Originally Posted by Gazco View Post
Thanks, these sites really helped a lot and answered my questions, but the last one also brought up one little one: in the second example the programmer used
  1. File.open('game', 'w+') do |f|
What does the string
  1. 'w+'
do and
  1. |f|
do please? Thanks once again for any help.
"w+" is a mode string; it truncates the file (or creates a new one if it doesn't exist)

|f| is a block. Basically it means that in the following code f refers to the file.

A quick example of a simple block:

  1. >> 5.times do |i|
  2. ?> puts i.to_s
  3. >> end
  4. 0
  5. 1
  6. 2
  7. 3
  8. 4
  9. => 5
Note to self... pocket cup
Reply With Quote Quick reply to this message  
Join Date: Mar 2007
Posts: 8
Reputation: Gazco is an unknown quantity at this point 
Solved Threads: 2
Gazco's Avatar
Gazco Gazco is offline Offline
Newbie Poster

Re: how do you use marshal.dump in Ruby please?

 
0
  #6
Apr 24th, 2007
Thank you this really helps!
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Ruby Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC