User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the Ruby section within the Web Development category of DaniWeb, a massive community of 427,809 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,832 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Ruby advertiser: SELL YOUR PRODUCT TODAY !
Views: 3645 | 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: 3
Solved Threads: 33
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: 3
Solved Threads: 33
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.

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

 

Thread Tools Display Modes

Similar Threads
Other Threads in the Ruby Forum

All times are GMT -4. The time now is 2:24 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC