るりまサーチ

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

別のキーワード

  1. forwardable def_delegator
  2. forwardable def_delegators
  3. erb def_method
  4. erb def_module
  5. erb def_class

ライブラリ

クラス

キーワード

検索結果

ERB#def_method(mod, methodname, fname='(ERB)') -> nil (18107.0)

変換した Ruby スクリプトをメソッドとして定義します。

...に活躍します。

@param mod メソッドを定義するモジュール(またはクラス)

@param methodname メソッド名

@param fname スクリプトを定義する際のファイル名

例:

require 'erb'
erb = ERB.new(script)
erb.def_method(MyClass, 'foo(bar)', 'foo.erb')...

Module#undef_method(*name) -> self (6100.0)

このモジュールのインスタンスメソッド name を未定義にします。

...end
end
class B < A
def ok
puts 'B'
end
end

B.new.ok # => B

# undef_method の場合はスーパークラスに同名のメソッドがあっても
# その呼び出しはエラーになる
class B
undef_method :ok
end
B.new.ok # => NameError

# remove_method の場合はスーパー...
...スに同名のメソッドがあると
# それが呼ばれる
class B
remove_method :ok
end
B.new.ok # => A
//}

また、undef 文と undef_method の違いは、
メソッド名を String または Symbol で与えられることです。

//emlist[例][ruby]{
module M1
def foo
end
def...
...self.moo
undef foo
end
end
M1.instance_methods false #=> ["foo"]
M1.moo
M1.instance_methods false #=> []
module M2
def foo
end
def self.moo
undef_method :foo
end
end
M2.instance_methods false #=> ["foo"]
M2.moo
M2.instance_methods false #=> []
//}...

static VALUE rb_mod_undef_method(VALUE mod, VALUE name) (6100.0)

void rb_undef_method(VALUE klass, const char *name) (6100.0)

クラス klass のインスタンスメソッド name を undef します。

クラス klass のインスタンスメソッド name を undef します。