別のキーワード
種類
- インスタンスメソッド (1018)
- モジュール関数 (211)
- 特異メソッド (105)
- クラス (44)
- オブジェクト (11)
クラス
- BasicObject (33)
- Enumerator (58)
-
Enumerator
:: Lazy (44) - Exception (11)
- Method (130)
- Module (250)
- NameError (22)
- NoMethodError (36)
- Object (165)
- Proc (50)
- Refinement (3)
- Regexp (44)
-
RubyVM
:: InstructionSequence (66) - String (55)
- Thread (11)
- TracePoint (39)
- UnboundMethod (98)
モジュール
- Kernel (189)
- Marshal (22)
-
RubyVM
:: AbstractSyntaxTree (8)
キーワード
- << (12)
- == (22)
- >> (12)
- Method (11)
- Numeric (11)
- Proc (11)
- UnboundMethod (11)
- [] (11)
-
_ _ callee _ _ (11) -
_ _ method _ _ (11) -
absolute
_ path (11) - args (11)
- arity (22)
- backtrace (11)
- bind (11)
-
callee
_ id (11) - caller (33)
-
class
_ exec (11) - curry (20)
-
define
_ method (22) - disasm (11)
- disassemble (11)
- dump (22)
- each (44)
- encode (33)
-
enum
_ for (44) - eql? (22)
- eval (22)
- fail (33)
-
first
_ lineno (11) - hash (22)
-
import
_ methods (3) - inspect (22)
-
instance
_ eval (22) -
instance
_ methods (11) - lambda (17)
- lambda? (11)
-
last
_ match (22) - main (11)
- match (22)
-
method
_ id (11) -
method
_ missing (11) - methods (11)
-
module
_ exec (11) -
module
_ function (19) - name (11)
- new (42)
- of (19)
- parameters (39)
- path (11)
- private (23)
-
private
_ call? (8) -
private
_ class _ method (15) -
private
_ instance _ methods (11) -
private
_ method _ defined? (11) -
private
_ methods (11) - proc (18)
- protected (23)
-
protected
_ instance _ methods (11) -
protected
_ method _ defined? (11) -
protected
_ methods (11) - public (23)
-
public
_ class _ method (15) -
public
_ instance _ method (11) -
public
_ instance _ methods (11) -
public
_ method (11) -
public
_ method _ defined? (11) -
public
_ methods (11) - raise (33)
-
require
_ relative (11) -
respond
_ to? (11) -
respond
_ to _ missing? (11) -
ruby2
_ keywords (5) - send (22)
-
singleton
_ methods (11) -
source
_ location (11) -
super
_ method (20) -
to
_ enum (44) -
to
_ proc (11) -
to
_ s (44) -
to
_ str (11)
検索結果
先頭5件
-
Method
# super _ method -> Method | nil (21380.0) -
self 内で super を実行した際に実行されるメソッドを Method オブジェ クトにして返します。
...uper を実行した際に実行されるメソッドを Method オブジェ
クトにして返します。
@see UnboundMethod#super_method
//emlist[例][ruby]{
class Super
def foo
"superclass method"
end
end
class Sub < Super
def 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"
//}... -
Object
# method(name) -> Method (18262.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... -
UnboundMethod
# super _ method -> UnboundMethod | nil (15315.0) -
self 内で super を実行した際に実行されるメソッドを UnboundMethod オブジェ クトにして返します。
...self 内で super を実行した際に実行されるメソッドを UnboundMethod オブジェ
クトにして返します。
@see Method#super_method... -
Method
# inspect -> String (15276.0) -
self を読みやすい文字列として返します。
...します。
以下の形式の文字列を返します。
#<Method: klass1(klass2)#method> (形式1)
klass1 は、Method#inspect では、レシーバのクラス名、
UnboundMethod#inspect では、UnboundMethod オブジェクトの生成
元となったクラス/モジュ......モジュール名、
method は、メソッド名を表します。
//emlist[例][ruby]{
module Foo
def foo
"foo"
end
end
class Bar
include Foo
def bar
end
end
p Bar.new.method(:foo) # => #<Method: Bar(Foo)#foo>
p Bar.new.method(:bar) # => #<Method: Bar#bar>
//}
klass......が同じ場合は以下の形式になります。
#<Method: klass1#method> (形式2)
特異メソッドに対しては、
#<Method: obj.method> (形式3)
#<Method: klass1(klass2).method> (形式4)
という形式の文字列......します。
以下の形式の文字列を返します。
#<Method: klass1(klass2)#method(arg) foo.rb:2> (形式1)
klass1 は、Method#inspect では、レシーバのクラス名、
UnboundMethod#inspect では、UnboundMethod オブジェクトの生成
元となったクラス/モジ......klass2 は、実際にそのメソッドを定義しているクラス/モジュール名、
method は、メソッド名を表します。
arg は引数を表します。
「foo.rb:2」は Method#source_location を表します。
source_location が nil の場合には付きません。
//em......Foo
def bar(a, b)
end
end
p Bar.new.method(:foo) # => #<Method: Bar(Foo)#foo() test.rb:2>
p Bar.new.method(:bar) # => #<Method: Bar#bar(a, b) test.rb:8>
//}
klass1 と klass2 が同じ場合は以下の形式になります。
#<Method: klass1#method() foo.rb:2> (... -
Method
# to _ proc -> Proc (15214.0) -
self を call する Proc オブジェクトを生成して返します。
...self を call する Proc オブジェクトを生成して返します。
//emlist[例][ruby]{
class Foo
def foo
"foo"
end
end
m = Foo.new.method(:foo) # => #<Method: Foo#foo>
pr = m.to_proc # => #<Proc:0x007f874d026008 (lambda)>
pr.call # => "foo"
//}... -
Method
# parameters -> [object] (15142.0) -
Method オブジェクトの引数の情報を返します。
...Method オブジェクトの引数の情報を返します。
Method オブジェクトが引数を取らなければ空の配列を返します。引数を取る場合は、配列の配列を返し、
各配列の要素は引数の種類に応じた以下のような Symbol と、仮引数の名......前を表す Symbol の 2 要素です。
組み込みのメソッドでは、仮引数の名前が取れません。
: :req
必須の引数
: :opt
デフォルト値が指定されたオプショナルな引数
: :rest
* で指定された残りすべての引数
: :keyreq
必須のキーワ......t[例][ruby]{
m = Class.new{define_method(:m){|x, y=42, *other, k_x:, k_y: 42, **k_other, &b|}}.instance_method(:m)
m.parameters #=> x], [:opt, :y], [:rest, :other], [:keyreq, :k_x], [:key, :k_y], [:keyrest, :k_other], [:block, :b
File.method(:symlink).parameters #=> req
//}
@see Proc#parameters......st[例][ruby]{
m = Class.new{define_method(:m){|x, y=42, *other, k_x:, k_y: 42, **k_other, &b|}}.instance_method(:m)
m.parameters #=> x], [:opt, :y], [:rest, :other], [:keyreq, :k_x], [:key, :k_y], [:keyrest, :k_other], [:block, :b
File.method(:symlink).parameters #=> req
//}
@see Proc#parameters... -
Object
# public _ method(name) -> Method (12368.0) -
オブジェクトの public メソッド name をオブジェクト化した Method オブジェクトを返します。
...クトの public メソッド 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... -
Module
# public _ instance _ method(name) -> UnboundMethod (12345.0) -
self の public インスタンスメソッド name をオブジェクト化した UnboundMethod を返します。
...elf の public インスタンスメソッド name をオブジェクト化した UnboundMethod を返します。
@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 (12311.0) -
インスタンスメソッド name がモジュールに定義されており、 しかもその可視性が private であるときに true を返します。 そうでなければ false を返します。
...がモジュールに定義されており、
しかもその可視性が private であるときに true を返します。
そうでなければ false を返します。
@param name Symbol か String を指定します。
@param inherit 真を指定するとスーパークラスや include した......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 (12311.0) -
インスタンスメソッド name がモジュールに定義されており、 しかもその可視性が protected であるときに true を返します。 そうでなければ false を返します。
...モジュールに定義されており、
しかもその可視性が protected であるときに true を返します。
そうでなければ false を返します。
@param name Symbol か String を指定します。
@param inherit 真を指定するとスーパークラスや include した......odule#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.protect......ed_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 (12311.0) -
インスタンスメソッド name がモジュールに定義されており、 しかもその可視性が public であるときに true を返します。 そうでなければ false を返します。
...がモジュールに定義されており、
しかもその可視性が public であるときに true を返します。
そうでなければ false を返します。
@param name Symbol か String を指定します。
@param inherit 真を指定するとスーパークラスや include した......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
//}...