るりまサーチ

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

別のキーワード

  1. objectspace each_object
  2. _builtin each_object
  3. object send
  4. object enum_for
  5. object to_enum

検索結果

<< 1 2 3 ... > >>

Object#instance_variables -> [Symbol] (27137.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#pretty_print_instance_variables -> [String | Symbol] (27101.0)

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

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

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

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

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

...elf のインスタンス変数や特異メソッドは変化しません。

デフォルトでは、Object#clone の内部で Object#initialize_clone から、
また Object#dup の内部で Object#initialize_dup から呼ばれます。

initialize_copy は、Ruby インタプリタが知り得...
...alize_copy でコピーするよう定義しておくことで、dup や clone
を再定義する必要がなくなります。

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

initialize_copy と...
...j = 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.taint

check Object.n...
...//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#instance_variable_set(var, value) -> object (21131.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_variable_get(var) -> object | nil (21125.0)

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

...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_variable_get(:@bar) #=> nil
//}

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

絞り込み条件を変える

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

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

..., @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::DATA -> File (21006.0)

スクリプトの __END__ プログラムの終り以降をアクセスする File オブジェクト。

...ん。
* Kernel.#require や Kernel.#load で
読み込まれたファイルの中であってもそのファイル (__FILE__, d:spec/variables#pseudo)
ではなく実行されたファイル ($0) を指します。

=== 例1
print DATA.gets # => 故人西辞黄鶴楼
print D...

WIN32OLE_TYPE#variables -> [WIN32OLE_VARIABLE] (18113.0)

型が持つ変数を取得します。

...ERuntimeError 型属性が取得できない場合に通知します。

tobj = WIN32OLE_TYPE.new('Microsoft Excel 14.0 Object Library', 'XlSheetType')
vars = tobj.variables
vars.each do |v|
puts "#{v.name} = #{v.value}"
end

上記を実行すると以下の出力が得られます...

Module#class_variables(inherit = true) -> [Symbol] (6143.0)

クラス/モジュールに定義されているクラス変数の名前の配列を返します。

...d
class Two < One
@@var2 = 2
end
One.class_variables # => [:@@var1]
Two.class_variables # => [:@@var2, :@@var1]
Two.class_variables(false) # => [:@@var2]
//}

@see Module.constants, Kernel.#local_variables, Kernel.#global_variables, Object#instance_variables, Module#constants...
<< 1 2 3 ... > >>