12件ヒット
[1-12件を表示]
(0.027秒)
別のキーワード
検索結果
先頭1件
-
Marshal フォーマット (3054.0)
-
Marshal フォーマット フォーマットバージョン 4.8 を元に記述しています。
...==== String, Regexp, Array, Hash のサブクラス (インスタンス変数あり)
'I' で始まるデータ構造になります。
d:marshal_format#instance_variableも参照してください。
//emlist[例 2: インスタンス変数あり][ruby]{
class Foo < Array # (or String, Regexp, Ha.......unpack("x2 a a c a3 c aca4 aca3 aca4 ac")
# => ["o", ":", 8, "Foo", 7,
# ":", 9, "@foo", ":", 8, "bar",
# ":", 9, "@one", "i", 6]
//}
=== Float
'f' で始まるデータ構造になります。
//emlist{
| 'f' | 数値列の長さ(Fixnum形式) | "%.16g" の文字列 |
//}
//emlist[][r......@bar = 1
end
p Bar.instance_eval { @bar } # => 1
File.open('testfile', 'wb') do |f|
Marshal.dump(Bar, f)
end
# 別プログラム相当にするため remove_const
Object.send :remove_const, :Bar
module Bar
end
p bar = Marshal.load(File.binread('testfile'))
p bar.instance_eval { @bar }
# => nil...