別のキーワード
キーワード
-
alias
_ method (12) -
class
_ exec (12) -
define
_ method (24) -
instance
_ method (12) -
instance
_ methods (12) -
method
_ added (12) -
method
_ defined? (12) -
method
_ removed (12) -
method
_ undefined (12) -
module
_ exec (12) -
module
_ function (36) - private (48)
-
private
_ class _ method (24) -
private
_ instance _ methods (12) -
private
_ method _ defined? (12) -
protected
_ method _ defined? (12) -
psych
_ yaml _ as (4) - public (48)
-
public
_ class _ method (24) -
public
_ instance _ method (12) -
public
_ method _ defined? (12) -
remove
_ method (12) -
ruby2
_ keywords (12) -
undef
_ method (12) -
yaml
_ as (4)
検索結果
先頭5件
-
Module
# ruby2 _ keywords(method _ name , . . . ) -> nil (6375.0) -
For the given method names, marks the method as passing keywords through a normal argument splat. This should only be called on methods that accept an argument splat (`*args`) but not explicit keywords or a keyword splat. It marks the method such that if the method is called with keyword arguments, the final hash argument is marked with a special flag such that if it is the final element of a normal argument splat to another method call, and that method call does not include explicit keywords or a keyword splat, the final element is interpreted as keywords. In other words, keywords will be passed through the method to other methods.
...For the given method names, marks the method as passing keywords through
a normal argument splat. This should only be called on methods that
accept an argument splat (`*args`) but not explicit keywords or a
keyword splat. It marks the method such that if the method is called
with keyword argument......ords. In other words, keywords will be passed through the method to
other methods.
This should only be used for methods that delegate keywords to another
method, and only for backwards compatibility with Ruby versions before
2.7.
This method will probably be removed at some point, as it exists onl......the module responds to this method before calling
it. Also, be aware that if this method is removed, the behavior of the
method will change so that it does not pass through keywords.
//emlist[例][ruby]{
module Mod
def foo(meth, *args, &block)
send(:"do_#{meth}", *args, &block)
end
ruby2_... -
Module
# method _ defined?(name , inherit=true) -> bool (6276.0) -
モジュールにインスタンスメソッド name が定義されており、 かつその可視性が public または protected であるときに true を返します。
...e Module#public_method_defined?, Module#private_method_defined?, Module#protected_method_defined?
//emlist[例][ruby]{
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......def 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"......#=> true
C.method_defined? "protected_method1" #=> true
C.method_defined? "method4" #=> false
C.method_defined? "private_method2" #=> false
//}... -
Module
# instance _ method(name) -> UnboundMethod (6244.0) -
self のインスタンスメソッド name をオブジェクト化した UnboundMethod を返します。
...した UnboundMethod を返します。
@param name メソッド名を Symbol または String で指定します。
@raise NameError self に存在しないメソッドを指定した場合に発生します。
@see Module#public_instance_method, Object#method
//emlist[例][ruby]{
class Interpr......() print "!\n"; end
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 }... -
Module
# define _ method(name , method) -> Symbol (6240.0) -
インスタンスメソッド name を定義します。
...ring または 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 (6238.0) -
self の public インスタンスメソッド name をオブジェクト化した UnboundMethod を返します。
...undMethod を返します。
@param name メソッド名を Symbol または String で指定します。
@raise NameError 定義されていないメソッド名や、
protected メソッド名、 private メソッド名を引数として与えると発生します。
//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 (6216.0) -
インスタンスメソッド name がモジュールに定義されており、 しかもその可視性が private であるときに true を返します。 そうでなければ false を返します。
...ります。
@see Module#method_defined?, Module#public_method_defined?, Module#protected_method_defined?
//emlist[例][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 (6216.0) -
インスタンスメソッド name がモジュールに定義されており、 しかもその可視性が protected であるときに true を返します。 そうでなければ false を返します。
...ります。
@see Module#method_defined?, Module#public_method_defined?, Module#private_method_defined?
//emlist[例][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 (6216.0) -
インスタンスメソッド name がモジュールに定義されており、 しかもその可視性が public であるときに true を返します。 そうでなければ false を返します。
...ます。
@see Module#method_defined?, Module#private_method_defined?, Module#protected_method_defined?
//emlist[例][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 #=> true
C.public_method_defined? "method1", false #=> true
C.public_method_defined? "method2" #=> false
C.method_defined? "method2" #=> true
//}... -
Module
# method _ undefined(name) -> () (6160.0) -
このモジュールのインスタンスメソッド name が Module#undef_method によって削除されるか、 undef 文により未定義にされると、インタプリタがこのメソッドを呼び出します。
...ンスメソッド name が
Module#undef_method によって削除されるか、
undef 文により未定義にされると、インタプリタがこのメソッドを呼び出します。
特異メソッドの削除をフックするには
BasicObject#singleton_method_undefined
を使います......ド名が Symbol で渡されます。
//emlist[例][ruby]{
class C
def C.method_undefined(name)
puts "method C\##{name} was undefined"
end
def foo
end
def bar
end
undef_method :foo
undef bar
end
//}
実行結果:
method C#foo was undefined
method C#bar was undefined...