Welcome to the "trac"-ing site of soap4r!
[soap4r] [httpclient] [openpgp4u] [pkcs1] [logger] [csv] [vtr]

root/branches/1_5/sample/marshal/digraph.rb

Revision 1843, 0.9 kB (checked in by nahi, 2 years ago)
  • reorganize sampless
  • Property svn:eol-style set to native
  • Property svn:keywords set to author date id revision
Line 
1 require 'soap/marshal'
2
3 class Node; include SOAP::Marshallable
4   attr_reader :first, :second, :str
5
6   def initialize(*init_next)
7     @first = init_next[0]
8     @second = init_next[1]
9   end
10 end
11
12 n9 = Node.new
13 n81 = Node.new(n9)
14 n82 = Node.new(n9)
15 n7 = Node.new(n81, n82)
16 n61 = Node.new(n7)
17 n62 = Node.new(n7)
18 n5 = Node.new(n61, n62)
19 n41 = Node.new(n5)
20 n42 = Node.new(n5)
21 n3 = Node.new(n41, n42)
22 n21 = Node.new(n3)
23 n22 = Node.new(n3)
24 n1 = Node.new(n21, n22)
25
26 File.open("digraph_marshalled_string.soap", "wb") do |f|
27   SOAP::Marshal.dump(n1, f)
28 end
29
30 marshalledString = File.open("digraph_marshalled_string.soap") { |f| f.read }
31
32 puts marshalledString
33
34 newnode = SOAP::Marshal.unmarshal(marshalledString)
35
36 puts newnode.inspect
37
38 p newnode.first.first.__id__
39 p newnode.second.first.__id__
40 p newnode.first.first.first.first.__id__
41 p newnode.second.first.second.first.__id__
42
43 File.unlink("digraph_marshalled_string.soap")
Note: See TracBrowser for help on using the browser.