Restore a marshall file

Hello I’m trying to learn ruby, and I have a question, how can I restore
a file marshall. That is to say retrieve the original file. Thank you in
advance, ruby is the first programming laguage I try to 'learn, so
please give me a clear answer . I’m French sorry for my bad english

Thanks,

On Wed, Oct 30, 2013 at 4:11 PM, Chuck N. [email protected] wrote:

Hello I’m trying to learn ruby, and I have a question, how can I restore
a file marshall. That is to say retrieve the original file. Thank you in
advance, ruby is the first programming laguage I try to 'learn, so
please give me a clear answer . I’m French sorry for my bad english

irb(main):004:0> x = rand(1000).to_s
=> “662”
irb(main):005:0> File.open(“data.bin”, “wb”) {|io| Marshal.dump(x, io)}
=> #<File:data.bin (closed)>
irb(main):006:0> y = File.open(“data.bin”, “rb”) {|io| Marshal.load(io)}
=> “662”
irb(main):007:0> x.equal? y
=> false
irb(main):008:0> x.object_id
=> 12886726380
irb(main):009:0> y.object_id
=> 12886713020

In this example “x” is just a sample value - could be any object.

Kind regards

rober

I tried using Marshal with my RubyExcel gem in IRB, and I got these
warnings:

(irb):6: warning: RubyExcel::Sheet#respond_to?(:marshal_dump) is old
fashion which takes only one parameter
C:/splice/bin/RubyExcel/lib/lib/rubyexcel/sheet.rb:430: warning:
respond_to? is defined here

My Google search didn’t turn up anything particularly relevant. Is this
warning part of IRB, Marshal… Ruby interpreter?

On 10/30/2013 09:00 AM, Joel P. wrote:

It’s a warning from Ruby:

Change is here:

Marshal calls rb_respond_to() which calls rb_obj_respond_to() which
issues that warning if an object’s respond_to? method doesn’t accept an
optional second argument:

$ irb
2.0.0p247 :001 > class A
2.0.0p247 :002?> def respond_to? meth
2.0.0p247 :003?> end
2.0.0p247 :004?> end
=> nil
2.0.0p247 :005 > Marshal.dump(A.new)
(irb):5: warning: A#respond_to?(:marshal_dump) is old fashion which
takes only one parameter
(irb):2: warning: respond_to? is defined here
(irb):5: warning: A#respond_to?(:_dump) is old fashion which takes only
one parameter
(irb):2: warning: respond_to? is defined here
=> “\x04\bo:\x06A\x00”