るりまサーチ

最速Rubyリファレンスマニュアル検索!
199件ヒット [1-100件を表示] (0.113秒)
トップページ > クエリ:i[x] > クエリ:instance[x] > クラス:Object[x]

別のキーワード

  1. _builtin to_i
  2. fiddle to_i
  3. matrix elements_to_i
  4. kernel $-i
  5. csv to_i

検索結果

<< 1 2 > >>

Object#pretty_print_instance_variables -> [String | Symbol] (18402.0)

プリティプリント時に表示すべき自身のインスタンス変数名の配列をソートして返します。 返されたインスタンス変数はプリティプリント時に表示されます。

プリティプリント時に表示すべき自身のインスタンス変数名の配列をソートして返します。
返されたインスタンス変数はプリティプリント時に表示されます。

pp に表示したくないインスタンス変数がある場合にこのメソッドを再定義します。

Object#instance_variable_defined?(var) -> bool (18338.0)

インスタンス変数 var が定義されていたら真を返します。

...//emlist[][ruby]{
class Fred
def initialize(p1, p2)
@a, @b = p1, p2
end
end
fred = Fred.new('cat', 99)
p fred.instance_variable_defined?(:@a) #=> true
p fred.instance_variable_defined?("@b") #=> true
p fred.instance_variable_defined?("@c") #=> false
//}

@see Object#instance_variable_...
...get,Object#instance_variable_set,Object#instance_variables...

Object#instance_variable_get(var) -> object | nil (12238.0)

オブジェクトのインスタンス変数の値を取得して返します。

...nil を返します。

@param var インスタンス変数名を文字列か Symbol で指定します。

//emlist[][ruby]{
class Foo
def initialize
@foo = 1
end
end

obj = Foo.new
p obj.instance_variable_get("@foo") #=> 1
p obj.instance_variable_get(:@foo) #=> 1
p obj.instance_v...
...ariable_get(:@bar) #=> nil
//}

@see Object#instance_variable_set,Object#instance_variables,Object#instance_variable_defined?...

Object#instance_variable_set(var, value) -> object (12238.0)

オブジェクトのインスタンス変数 var に値 value を設定します。

...value を返します。

//emlist[][ruby]{
obj = Object.new
p obj.instance_variable_set("@foo", 1) #=> 1
p obj.instance_variable_set(:@foo, 2) #=> 2
p obj.instance_variable_get(:@foo) #=> 2
//}

@see Object#instance_variable_get,Object#instance_variables,Object#instance_variable_defined?...

Object#instance_of?(klass) -> bool (12220.0)

オブジェクトがクラス klass の直接のインスタンスである時真を返します。

...

obj.instance_of?(c) が成立する時には、常に obj.kind_of?(c) も成立します。

@param klass Classかそのサブクラスのインスタンスです。

//emlist[][ruby]{
class C < Object
end
class S < C
end

obj = S.new
p obj.instance_of?(S) # true
p obj.instance_of?(C)...
...# false
//}

@see Object#kind_of?,Object#class...

絞り込み条件を変える

Object#instance_variables -> [Symbol] (12220.0)

オブジェクトのインスタンス変数名をシンボルの配列として返します。

...列として返します。

//emlist[][ruby]{
obj = Object.new
obj.instance_eval { @foo, @bar = nil }
p obj.instance_variables

#=> [:@foo, :@bar]
//}

@see Object#instance_variable_get, Kernel.#local_variables, Kernel.#global_variables, Module.constants, Module#constants, Module#class_variables...

Object#remove_instance_variable(name) -> object (12220.0)

オブジェクトからインスタンス変数 name を取り除き、そのインス タンス変数に設定されていた値を返します。

...ます。
@raise NameError オブジェクトがインスタンス変数 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 (NameErr...
...or)
end
end
Foo.new.foo
//}

@see Module#remove_class_variable,Module#remove_const...

Object#must_be_instance_of(klass) -> true (12208.0)

自身が与えられたクラスのインスタンスである場合、検査にパスしたことになります。

...ンスである場合、検査にパスしたことになります。

@param klass 任意のクラスを指定します。

@raise MiniTest::Assertion 自身が与えられたクラスの直接のインスタンスでない場合に発生します。

@see MiniTest::Assertions#assert_instance_of...

Object#initialize_copy(obj) -> object (6125.0)

(拡張ライブラリによる) ユーザ定義クラスのオブジェクトコピーの初期化メソッド。

...で置き換えます。ただ
し、self のインスタンス変数や特異メソッドは変化しません。
Object
#clone, Object#dupの内部で使われています。

i
nitialize_copy は、Ruby インタプリタが知り得ない情報をコピーするた
めに使用(定義)されます...
... initialize_copy でコピーするよう定義しておくことで、dup や clone
を再定義する必要がなくなります。

デフォルトの Object#initialize_copy は、 freeze チェックおよび型のチェックを行い self
を返すだけのメソッドです。

i
nitialize_...
...mlist[][ruby]{
obj = Object.new
class <<obj
attr_accessor :foo
def bar
:bar
end
end

def check(obj)
puts "instance variables: #{obj.inspect}"
puts "tainted?: #{obj.tainted?}"
print "singleton methods: "
begin
p obj.bar
rescue NameError
p $!
end
end

obj.foo = 1
obj.tain...
...//emlist[][ruby]{
obj = Object.new
class <<obj
attr_accessor :foo
def bar
:bar
end
end

def check(obj)
puts "instance variables: #{obj.inspect}"
print "singleton methods: "
begin
p obj.bar
rescue NameError
p $!
end
end

obj.foo = 1

check Object.new.send(:initialize_cop...

Object#is_a?(mod) -> bool (6107.0)

オブジェクトが指定されたクラス mod かそのサブクラスのインスタンスであるとき真を返します。

...をインクルードしたクラスかそのサブクラス
のインスタンスである場合にも真を返します。
Module#includeだけではなく、Object#extendやModule#prependに
よってサブクラスのインスタンスになる場合も含みます。
上記のいずれでも...
...です。

//emlist[][ruby]{
module M
end
class C < Object
i
nclude M
end
class S < C
end

obj = S.new
p obj.is_a?(S) # true
p obj.is_a?(C) # true
p obj.is_a?(Object) # true
p obj.is_a?(M) # true
p obj.is_a?(Hash) # false
//}

@see Object#instance_of?,Module#===,Object#class...

絞り込み条件を変える

<< 1 2 > >>