るりまサーチ

最速Rubyリファレンスマニュアル検索!
1695件ヒット [1-100件を表示] (0.065秒)
トップページ > クエリ:d[x] > クエリ:method[x] > ライブラリ:ビルトイン[x]

別のキーワード

  1. bigdecimal/util to_d
  2. float to_d
  3. kernel $-d
  4. rsa d
  5. matrix d

クラス

モジュール

オブジェクト

キーワード

検索結果

<< 1 2 3 ... > >>

Object#method(name) -> Method (24350.0)

オブジェクトのメソッド name をオブジェクト化した Method オブジェクトを返します。

...した
Method
オブジェクトを返します。

@param name メソッド名をSymbol またはStringで指定します。
@raise NameError 定義されていないメソッド名を引数として与えると発生します。

//emlist[][ruby]{
me = -365.method(:abs)
p me #=> #<Method: Integer#...
...abs>
p me.call #=> 365
//}

@see Module#instance_method, Method, BasicObject#__send__, Object#send, Kernel.#eval, Object#singleton_method...

Method#super_method -> Method | nil (21480.0)

self 内で super を実行した際に実行されるメソッドを Method オブジェ クトにして返します。

...るメソッドを Method オブジェ
クトにして返します。

@see UnboundMethod#super_method

//emlist[例][ruby]{
class Super
d
ef foo
"superclass method"
end
end

class Sub < Super
d
ef foo
"subclass method"
end
end

m = Sub.new.method(:foo) # => #<Method: Sub#foo>
m.call #...
...=> "subclass method"
m.super_method # => #<Method: Super#foo>
m.super_method.call # => "superclass method"
//}...

UnboundMethod#super_method -> UnboundMethod | nil (15415.0)

self 内で super を実行した際に実行されるメソッドを UnboundMethod オブジェ クトにして返します。

...self 内で super を実行した際に実行されるメソッドを UnboundMethod オブジェ
クトにして返します。


@see Method#super_method...

Module#protected_method_defined?(name, inherit=true) -> bool (15411.0)

インスタンスメソッド name がモジュールに定義されており、 しかもその可視性が protected であるときに true を返します。 そうでなければ false を返します。

...り、
しかもその可視性が protected であるときに true を返します。
そうでなければ false を返します。

@param name Symbol か String を指定します。
@param inherit 真を指定するとスーパークラスや include したモジュールで
定義さ...
...ます。

@see Module#method_defined?, Module#public_method_defined?, Module#private_method_defined?

//emlist[例][ruby]{
module A
d
ef method1() end
end
class B
protected
d
ef method2() end
end
class C < B
include A
d
ef method3() end
end

A.method_defined? :method1 #...
...=> true
C.protected_method_defined? "method1" #=> false
C.protected_method_defined? "method2" #=> true
C.protected_method_defined? "method2", true #=> true
C.protected_method_defined? "method2", false #=> false
C.method_defined? "method2" #=> true
//}...

Method#unbind -> UnboundMethod (15332.0)

self のレシーバとの関連を取り除いた UnboundMethod オブ ジェクトを生成して返します。

...除いた UnboundMethod オブ
ジェクトを生成して返します。

//emlist[例][ruby]{
class Foo
d
ef foo
"foo"
end
end

m = Foo.new.method(:foo) # => #<Method: Foo#foo>
unbound_method = m.unbind # => #<UnboundMethod: Foo#foo>
unbound_method.bind(Foo.new) # => #<Method: Foo#foo>
//}...

絞り込み条件を変える

Module#method_defined?(name, inherit=true) -> bool (12371.0)

モジュールにインスタンスメソッド name が定義されており、 かつその可視性が public または protected であるときに true を返します。

...cted であるときに
true を返します。

@param name Symbol か String を指定します。
@param inherit 真を指定するとスーパークラスや include したモジュールで
定義されたメソッドも対象になります。

@see Module#public_method_defined?, Module...
...ate_method_defined?, Module#protected_method_defined?

//emlist[例][ruby]{
module A
d
ef method1() end
d
ef protected_method1() end
protected :protected_method1
end
class B
d
ef method2() end
d
ef private_method2() end
private :private_method2
end
class C < B
include A
d
ef method3()...
...end
end

A.method_defined? :method1 #=> true
C.method_defined? "method1" #=> true
C.method_defined? "method2" #=> true
C.method_defined? "method2", true #=> true
C.method_defined? "method2", false #=> false
C.method_defined? "method3" #=>...

Module#instance_method(name) -> UnboundMethod (12357.0)

self のインスタンスメソッド name をオブジェクト化した UnboundMethod を返します。

...ndMethod を返します。

@param name メソッド名を Symbol または String で指定します。

@raise NameError self に存在しないメソッドを指定した場合に発生します。

@see Module#public_instance_method, Object#method

//emlist[例][ruby]{
class Interpreter
d
ef d...
...int "there, "; end
d
ef do_d() print "Hello "; end
d
ef do_e() print "!\n"; end
d
ef do_v() print "Dave"; end
D
ispatcher = {
"a" => instance_method(:do_a),
"d" => instance_method(:do_d),
"e" => instance_method(:do_e),
"v" => instance_method(:do_v)
}
d
ef interpret(str...
...ing)
string.each_char {|b| Dispatcher[b].bind(self).call }
end
end

interpreter = Interpreter.new
interpreter.interpret('dave')
# => Hello there, Dave!
//}...

Object#public_method(name) -> Method (12356.0)

オブジェクトの public メソッド name をオブジェクト化した Method オブジェクトを返します。

...メソッド name をオブジェクト化した
Method
オブジェクトを返します。

@param name メソッド名を Symbol または String で指定します。
@raise NameError 定義されていないメソッド名や、
protected メソッド名、 private メソッド名を引...
...数として与えると発生します。

//emlist[][ruby]{
1.public_method(:to_int) #=> #<Method: Integer#to_int>
1.public_method(:p) # method `p' for class `Integer' is private (NameError)
//}

@see Object#method,Object#public_send,Module#public_instance_method...

Object#singleton_method(name) -> Method (12356.0)

オブジェクトの特異メソッド name をオブジェクト化した Method オブ ジェクトを返します。

... Method オブ
ジェクトを返します。

@param name メソッド名をSymbol またはStringで指定します。
@raise NameError 定義されていないメソッド名を引数として与えると発生します。

//emlist[][ruby]{
class Demo
d
ef initialize(n)
@iv = n
end
d
ef...
...iv}"
end
end

k = Demo.new(99)
d
ef k.hi
"Hi, @iv = #{@iv}"
end
m = k.singleton_method(:hi) # => #<Method: #<Demo:0xf8b0c3c4 @iv=99>.hi>
m.call #=> "Hi, @iv = 99"
m = k.singleton_method(:hello) # => NameError
//}

@see Module#instance_method, Method, BasicObject#__send__, Object#send, Kernel...
....#eval, Object#method...
<< 1 2 3 ... > >>