44件ヒット
[1-44件を表示]
(0.047秒)
別のキーワード
種類
- インスタンスメソッド (33)
- 文書 (11)
ライブラリ
- ビルトイン (33)
キーワード
- Marshal フォーマット (11)
-
remove
_ class _ variable (11) -
remove
_ instance _ variable (11)
検索結果
先頭4件
-
Module
# remove _ const(name) -> object (18207.0) -
name で指定した定数を取り除き、その定数に設定されていた値を 返します。
...定数がそのモジュールやクラスに定義されていない場合に発生します。
//emlist[例][ruby]{
class Foo
FOO = 1
p remove_const(:FOO) # => 1
p FOO # => uninitialized constant FOO at Foo (NameError)
end
//}
組み込みクラス/モジュールを設定してい... -
Marshal フォーマット (210.0)
-
Marshal フォーマット フォーマットバージョン 4.8 を元に記述しています。
...て
//emlist{
n == 0: 0
0 < n < 123: n + 5
-124 < n < 0: n - 5
//}
という数値(1 byte)を格納します。5 を足したり引いたりするのは下記の
形式 2 との区別のためです。
//emlist[例][ruby]{
p Marshal.dump(-1).unpack1("x2 a*") # => "i\xFA"
p Marshal.dump(0).......|
<-1-> <- len ->
byte bytes
//}
len の値は -4 〜 -1, 1 〜 4 で。符号と後続のデータが n1 〜 n_len
まであることを示します。
//emlist[][ruby]{
def foo(len, n1, n2 = 0, n3 = 0, n4 = 0)
case len
when -3; n4 = 255
when -2;......tance_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
//}
//emlist[例 3:... -
Module
# remove _ class _ variable(name) -> object (106.0) -
引数で指定したクラス変数を取り除き、そのクラス変数に設定さ れていた値を返します。
...ールやクラスに定義されていない場合に発生します。
//emlist[例][ruby]{
class Foo
@@foo = 1
remove_class_variable(:@@foo) # => 1
p @@foo # => uninitialized class variable @@foo in Foo (NameError)
end
//}
@see Module#remove_const, Object#remove_instance_variable... -
Object
# remove _ instance _ variable(name) -> object (106.0) -
オブジェクトからインスタンス変数 name を取り除き、そのインス タンス変数に設定されていた値を返します。
...ない場合に発生します。
//emlist[][ruby]{
class Foo
def foo
@foo = 1
p remove_instance_variable(:@foo) #=> 1
p remove_instance_variable(:@foo) # instance variable @foo not defined (NameError)
end
end
Foo.new.foo
//}
@see Module#remove_class_variable,Module#remove_const...