るりまサーチ

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

別のキーワード

  1. singleton instance
  2. singleton clone
  3. singleton dup
  4. _builtin define_singleton_method
  5. object define_singleton_method

ライブラリ

キーワード

検索結果

Object#methods(include_inherited = true) -> [Symbol] (18324.0)

そのオブジェクトに対して呼び出せるメソッド名の一覧を返します。 このメソッドは public メソッドおよび protected メソッドの名前を返します。

...ソッドの名前を返します。

ただし特別に、引数が偽の時は Object#singleton_methods(false) と同じになっています。


@param include_inherited 引数が偽の時は Object#singleton_methods(false) と同じになります。

//emlist[例1][ruby]{
class Parent
privat...
...ate_singleton() end
protected; def protected_singleton() end
public; def public_singleton() end
end

# あるオブジェクトの応答できるメソッドの一覧を得る。
p obj.methods(false)
p obj.public_methods(false)
p obj.private_methods(false)
p obj.protected_methods(fal...
...# いるが、Object のインスタンスメソッドは一覧から排除している。
p obj.methods(true) - Object.instance_methods(true)
p obj.public_methods(true) - Object.public_instance_methods(true)
p obj.private_methods(true) - Object.private_instance_methods(true)
p obj.p...

Object#private_methods(include_inherited = true) -> [Symbol] (6132.0)

そのオブジェクトが理解できる private メソッド名の一覧を返します。

...が理解できる private メソッド名の一覧を返します。

@param include_inherited 偽となる値を指定すると自身のクラスのスーパークラスで定義されたメソッドを除きます。


@see Module#private_instance_methods,Object#methods,Object#singleton_methods...

Object#protected_methods(include_inherited = true) -> [Symbol] (6132.0)

そのオブジェクトが理解できる protected メソッド名の一覧を返します。

...解できる protected メソッド名の一覧を返します。

@param include_inherited 偽となる値を指定すると自身のクラスのスーパークラスで定義されたメソッドを除きます。


@see Module#protected_instance_methods,Object#methods,Object#singleton_methods...

Object#public_methods(include_inherited = true) -> [Symbol] (6132.0)

そのオブジェクトが理解できる public メソッド名の一覧を返します。

...が理解できる public メソッド名の一覧を返します。

@param include_inherited 偽となる値を指定すると自身のクラスのスーパークラスで定義されたメソッドを除きます。


@see Module#public_instance_methods,Object#methods,Object#singleton_methods...

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

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

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

initialize_copy は、Ruby インタプリタが知り得ない情報をコピーするた
めに...
...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...
...e_copy, obj)
#=> instance variables: #<Object:0x4019c9d4>
# tainted?: false
# singleton methods: #<NoMethodError: ...>
check obj.dup
#=> instance variables: #<Object:0x4019c9c0 @foo=1>
# tainted?: true
# singleton methods: #<NoMethodError: ...>...
...//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:0x4019c9d4>
# singleton methods: #<NoMethodError: ...>
check obj.dup
#=> instance variables: #<Object:0x4019c9c0 @foo=1>
# singleton methods: #<NoMethodError: ...>
check obj.clone
#=> instance variables: #<Object:0x4019c880 @foo=1>
# singleton m...

絞り込み条件を変える