RSS Forums RSS
Please support our Ruby advertiser: SELL YOUR PRODUCT TODAY !
Views: 3933 | Replies: 5 | Solved
Reply
Join Date: Mar 2007
Posts: 8
Reputation: Gazco is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 2
Gazco's Avatar
Gazco Gazco is offline Offline
Newbie Poster

Question how do you use marshal.dump in Ruby please?

  #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!
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Oct 2005
Location: Manchester, UK
Posts: 482
Reputation: pty is on a distinguished road 
Rep Power: 4
Solved Threads: 34
pty's Avatar
pty pty is offline Offline
Posting Pro in Training

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

  #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  
Join Date: Apr 2007
Location: Pune, India
Posts: 9
Reputation: IndianGuru is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 1
IndianGuru IndianGuru is offline Offline
Newbie Poster

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

  #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  
Join Date: Mar 2007
Posts: 8
Reputation: Gazco is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 2
Gazco's Avatar
Gazco Gazco is offline Offline
Newbie Poster

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

  #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
File.open('game', 'w+') do |f|
What does the string do and do please? Thanks once again for any help.
Reply With Quote  
Join Date: Oct 2005
Location: Manchester, UK
Posts: 482
Reputation: pty is on a distinguished road 
Rep Power: 4
Solved Threads: 34
pty's Avatar
pty pty is offline Offline
Posting Pro in Training

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

  #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
File.open('game', 'w+') do |f|
What does the string do and 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:

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

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

  #6  
Apr 24th, 2007
Thank you this really helps!
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes
Forums | Blogs | Tutorials | Code Snippets | Whitepapers | RSS Feeds | Advertising
All times are GMT -4. The time now is 10:13 am.
Newsletter Archive - Sitemap - Privacy Statement - Acceptable Use Policy - Contact Us
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC