Thanks for your time!
I get a class like this
class Vuser def start (logfile_name, iteration_hash) @logfile_name = logfile_name @iteration_hash = iteration_hash end attr_accessor: logfile_name ,: iteration_hash def Output_iteration_info () says @logfile_name @iteration_hash puts the end end and there will be an array to store examples of vusor class. Assume that the name of the array is vuser_ary.
I want to store this array (vuser_ary) in a binary file and I think it is called serialization. I can get it martial in google and standard library. Here's an example of how I do this on the Internet according to this example:
#serialization File.open ("some.file", "wb"). File | Marshall Dump (vuser_ary, file) End # loading vuser_ary = Zero file. Open ("some.file", "rb") {| F | Vuser_ary = Marshal.load (f)} But when I check something size File. I think it's just four bytes, so I know that some data stored in. The file can be referenced but the value of vuser_ary is not.
Then my question is how do I store the value of vuser_ary in a binary file. How do I change my code to get this? ! Thanks in advance
The stored value in Btw: vuser_ary will be as follows:
RO_3.2_S4_CommericalRealEstate1_274.log
{1 = & gt; "Unsuccessful" 2 = & gt; "Unsuccessful", 3 = & gt; "Pass", 4 = & gt; "Pass", 5 = & gt; "Unsuccessful"}
RO_3.2_S4_CommericalRealEstate1_275.log
{11 = & gt; "Failed", 2 = & gt; "Failed", 3 = & gt; "Failed", 4 = & gt; "Pass", 5 = & gt; "Unsuccessful"
RO_3 .2_S4_CommericalRealEstate1_276.log
{1 = & gt; "Unsuccessful", 2 = & gt; "Unsuccessful", 3 = & gt; "Pass", 4 = & gt; "Pass", 5 = & gt; "Fail"}
RO_3.2_S4_CommericalRealEstate1_277.log
{1 = "Fail", 2 => "Failed", 3 = & gt; "Pass" , 4 = & gt; "Failed", 5 = & gt; "Fail"}
RO_3.2_S4_CommericalRealEstate1_278.log
{1 = & gt; "Failed", 2 = & gt; "Unsuccessful", 3 = & gt; "Pass", 4 = & gt; "Pass", 5 = & gt; "Unsuccessful"}
RO_3.2_S4_CommericalRealEstate1_279.log
{1 = & gt; "Unsuccessful", 2 = & gt; "Unsuccessful", 3 = & gt; "Pass", 4 = & gt; "Pass", 5 = & gt; "Unsuccessful"}
RO_3.2_S4_CommericalRealEstate1_280.log
{1 = & gt; "Failed", 2 = & gt; "Failed", 3 = & gt; "Failed", 4 = & gt; "Pass", 5 = & gt; "Fail"}
Four bytes? It happens that martializing the empty table [] produces a 4-byte string on my Ruby: & gt; Marshall Stands ([]). Length = & gt; 4 Are you sure that vuser_ary is empty when you try to martial it? This happens, for reference "objects and objects: there are no signs in Ruby, so if you have an array (and it is empty), then it will be martial:
& gt; Marshal Dump ([1, 2, 3]). Length => 10 For good measure:
& gt; Vuser_ary = [{1 = "Failed", 2 = & gt; "Failed", 3 = & gt; "Pass", 4 = & gt; "Pass", 5 = & gt; ; "Failed"}] = & gt; [1 = & gt; "failed", 2 = & gt; "failed", 3 = & gt; "pass", 4 = & gt; "pass", 5 = & Gt; "failed"}] & gt; Marshall Dump (vuser_ary). Length => 72
Comments
Post a Comment