るりまサーチ

最速Rubyリファレンスマニュアル検索!
372件ヒット [1-100件を表示] (0.112秒)

別のキーワード

  1. string []=
  2. string slice
  3. string []
  4. string slice!
  5. string gsub

検索結果

<< 1 2 3 ... > >>

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

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

...す。

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

@
see Module#public_method_defined?, Module#private_method_defined?, Module#protecte...
...by]{
module
A
def method1() end
def protected_method1() end
protected :protected_method1
end
class B
def method2() end
def private_method2() end
private :private_method2
end
class C < B
include A
def method3() end
end

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

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

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

...クト化した UnboundMethod を返します。

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

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

@
see Module#public_instance_method, Object#method

//emlist[例][ruby]{
clas...
...def do_v() print "Dave"; end
Dispatcher = {
"a" => instance_method(:do_a),
"d" => instance_method(:do_d),
"e" => instance_method(:do_e),
"v" => instance_method(:do_v)
}
def interpret(string)
string
.each_char {|b| Dispatcher[b].bind(self).call }
end
end

interpreter...

Module#define_method(name, method) -> Symbol (6265.0)

インスタンスメソッド name を定義します。

...す。

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

@
param method Proc、Method あるいは UnboundMethod
いずれかのインスタンスを指定します。

@
return メソッド名を表す Symbol を返します。

@
raise TypeError method に同...
...じクラス、サブクラス、モジュール以外のメソッ
ドを指定した場合に発生します。

//emlist[例][ruby]{
class Foo
def foo() p :foo end
define_method(:bar, instance_method(:foo))
end
Foo.new.bar # => :foo
//}...

Module#public_instance_method(name) -> UnboundMethod (6257.0)

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

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

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

@
raise NameError 定義されていないメソッド名や、
protected メソッド名、 priva...
...として与えると発生します。

//emlist[例][ruby]{
Kernel.public_instance_method(:object_id) #=> #<UnboundMethod: Kernel#object_id>
Kernel.public_instance_method(:p) # method `p' for module `Kernel' is private (NameError)
//}

@
see Module#instance_method,Object#public_method...

Module#private_method_defined?(name, inherit=true) -> bool (6235.0)

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

...

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

@
see Module#method_defined?, Module#public_method_defined?, Module#protected_method_de...
...ist[例][ruby]{
module
A
def method1() end
end
class B
private
def method2() end
end
class C < B
include A
def method3() end
end

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

絞り込み条件を変える

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

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

...

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

@
see Module#method_defined?, Module#public_method_defined?, Module#private_method_defi...
...[例][ruby]{
module
A
def method1() end
end
class B
protected
def method2() end
end
class C < B
include A
def 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
//}...

Module#public_method_defined?(name, inherit=true) -> bool (6235.0)

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

...

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

@
see Module#method_defined?, Module#private_method_defined?, Module#protected_method_d...
...mlist[例][ruby]{
module
A
def method1() end
end
class B
protected
def method2() end
end
class C < B
include A
def method3() end
end

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

Module#define_method(name) { ... } -> Symbol (6165.0)

インスタンスメソッド name を定義します。

...す。

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

@
param method Proc、Method あるいは UnboundMethod
いずれかのインスタンスを指定します。

@
return メソッド名を表す Symbol を返します。

@
raise TypeError method に同...
...じクラス、サブクラス、モジュール以外のメソッ
ドを指定した場合に発生します。

//emlist[例][ruby]{
class Foo
def foo() p :foo end
define_method(:bar, instance_method(:foo))
end
Foo.new.bar # => :foo
//}...

Module#alias_method(new, original) -> Symbol (6163.0)

メソッドの別名を定義します。

...ソッドの別名を定義します。

//emlist[例][ruby]{
module
Kernel
alias_method :hoge, :puts # => :hoge
alias_method "foo", :puts # => :foo
end
//}

alias との違いは以下の通りです。

* メソッド名は String または Symbol で指定します
* グローバル変数...
...できません。

@
param new 新しいメソッド名。String または Symbol で指定します。

@
param original 元のメソッド名。String または Symbol で指定します。

@
return 作成したエイリアスのメソッド名を表す Symbol を返します。

@
see d:spec/def#al...
...ias

//emlist[例][ruby]{
module
Kernel
alias_method :foo, :puts
end

foo "bar" # bar
//}...
<< 1 2 3 ... > >>