Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8195435
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T05:08:15+00:00 2026-06-07T05:08:15+00:00

thanks for your time! I get a class like this class Vuser def initialize

  • 0

thanks for your time!

I get a class like this

class Vuser

    def initialize (logfile_name, iteration_hash)
        @logfile_name = logfile_name
        @iteration_hash = iteration_hash
    end

    attr_accessor :logfile_name, :iteration_hash

    def output_iteration_info ()
        puts @logfile_name
        puts @iteration_hash
    end
end

And there’s will be an array to store the instance of Vuser Class. Let’s say the array’s name is vuser_ary.

I want to store this array ( vuser_ary ) to a binary file and I think it’s called serialization. I google it and find Marshal in the standard library can do this.
Here’s an example how I do this according to the example on the Internet :

#serialization
File.open("some.file","wb") do |file|
   Marshal.dump(vuser_ary,file)
end

#loading
vuser_ary = nil
File.open("some.file","rb") {|f| vuser_ary = Marshal.load(f)}

But when I check the size of some.file. I find it’s just four bytes. Then I realize that the data stored in some.file may be the reference but not the value of the vuser_ary.

Then my question is how do I store the value of vuser_ary to a binary file. How do I change my code to achieve that? Thanks in advance!

BTW: the value stored in vuser_ary will be like this :

RO_3.2_S4_CommericalRealEstate1_274.log

{1=>”Fail”, 2=>”Fail”, 3=>”Pass”, 4=>”Pass”, 5=>”Fail”}

RO_3.2_S4_CommericalRealEstate1_275.log

{11=>”Fail”, 2=>”Fail”, 3=>”Fail”, 4=>”Pass”, 5=>”Fail”

RO_3.2_S4_CommericalRealEstate1_276.log

{1=>”Fail”, 2=>”Fail”, 3=>”Pass”, 4=>”Pass”, 5=>”Fail”}

RO_3.2_S4_CommericalRealEstate1_277.log

{1=>”Fail”, 2=>”Fail”, 3=>”Pass”, 4=>”Pass”, 5=>”Fail”}

RO_3.2_S4_CommericalRealEstate1_278.log

{1=>”Fail”, 2=>”Fail”, 3=>”Pass”, 4=>”Pass”, 5=>”Fail”}

RO_3.2_S4_CommericalRealEstate1_279.log

{1=>”Fail”, 2=>”Fail”, 3=>”Pass”, 4=>”Pass”, 5=>”Fail”}

RO_3.2_S4_CommericalRealEstate1_280.log

{1=>”Fail”, 2=>”Fail”, 3=>”Fail”, 4=>”Pass”, 5=>”Fail”}

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T05:08:17+00:00Added an answer on June 7, 2026 at 5:08 am

    Four bytes? It so happens that marshalling the empty array [] produces a 4-byte string on my Ruby:

    > Marshal.dump([]).length
     => 4 
    

    Are you sure vuser_ary isn’t empty when you try marshalling it?

    As it happens, there’s no difference between a “reference” to an object and the object itself: there are no pointers in Ruby, so if you have an array (and it’s non-empty), then it’ll get marshalled:

    > Marshal.dump([1, 2, 3]).length
     => 10
    

    For good measure:

    > vuser_ary = [{1=>"Fail", 2=>"Fail", 3=>"Pass", 4=>"Pass", 5=>"Fail"}]
     => [{1=>"Fail", 2=>"Fail", 3=>"Pass", 4=>"Pass", 5=>"Fail"}] 
    > Marshal.dump(vuser_ary).length
     => 72  
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hi everybody and thanks for your time, I read filenames in a QList. This
first of all thanks for taking your time! I'm a junior Dev, working with
Thanks for your help! I'd like to output all companyName entries that have uploads
and thanks in advance for your time. We are using CSLA 3.5.1, although, ultimately,
thanks for your time first...after all the searching on google, github and here, and
I've build a class like this: private class TestResults { public bool IsAdmitted {
I have a class like this: @interface MyCollection : NSObject { NSMutableDictionary *data; }
First of all thank you for your time and sorry if some issues are
thanks for your reading. I am trying to modify Jquery Nivo Zoom plugin to
Thanks For your Valuable support, Now i m able to run shell script in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.