2173件ヒット
[1-100件を表示]
(0.119秒)
ライブラリ
クラス
- Array (10)
- BasicObject (72)
- CGI (12)
- ERB (36)
- Enumerator (62)
-
Enumerator
:: Lazy (48) - Exception (12)
-
IRB
:: ExtendCommand :: Help (12) - Method (271)
- Module (380)
-
Net
:: HTTPGenericRequest (12) - Object (180)
- PP (12)
- Proc (24)
- Refinement (4)
- Regexp (48)
-
RubyVM
:: InstructionSequence (108) - String (60)
- Thread (12)
- TracePoint (43)
- UnboundMethod (156)
-
WIN32OLE
_ EVENT (12) -
WIN32OLE
_ METHOD (12) -
WIN32OLE
_ TYPE (12)
モジュール
- FileUtils (12)
-
JSON
:: Generator :: GeneratorMethods :: Array (12) -
JSON
:: Generator :: GeneratorMethods :: FalseClass (12) -
JSON
:: Generator :: GeneratorMethods :: Float (12) -
JSON
:: Generator :: GeneratorMethods :: Hash (12) -
JSON
:: Generator :: GeneratorMethods :: Integer (12) -
JSON
:: Generator :: GeneratorMethods :: NilClass (12) -
JSON
:: Generator :: GeneratorMethods :: Object (12) -
JSON
:: Generator :: GeneratorMethods :: String (12) -
JSON
:: Generator :: GeneratorMethods :: String :: Extend (12) -
JSON
:: Generator :: GeneratorMethods :: TrueClass (12) - Kernel (108)
- Marshal (24)
-
Net
:: HTTPHeader (12) - ObjectSpace (12)
-
RubyVM
:: AbstractSyntaxTree (10)
キーワード
-
1
. 6 . 8から1 . 8 . 0への変更点(まとめ) (12) - << (7)
- == (24)
- === (8)
- >> (7)
- BasicObject (12)
- InstructionSequence (12)
-
NEWS for Ruby 2
. 0 . 0 (12) -
NEWS for Ruby 2
. 2 . 0 (11) -
NEWS for Ruby 2
. 3 . 0 (10) -
NEWS for Ruby 3
. 1 . 0 (4) -
RUBY
_ METHOD _ FUNC (12) - UnboundMethod (12)
- [] (24)
-
_ _ method _ _ (12) -
absolute
_ path (12) -
alias
_ method (12) - arity (24)
- backtrace (12)
-
base
_ label (12) - bind (12)
-
bind
_ call (12) - call (24)
-
callee
_ id (12) - caller (36)
-
class
_ exec (12) - clone (24)
-
collect
_ method (12) -
count
_ nodes (12) - curry (22)
-
def
_ class (12) -
def
_ method (12) -
def
_ module (12) -
default
_ event _ sources (12) -
define
_ method (24) -
define
_ singleton _ method (24) - dig (10)
- disasm (12)
- disassemble (12)
- dump (24)
- each (48)
- encode (36)
-
enum
_ for (48) - eql? (24)
- eval (24)
- execute (12)
- fail (12)
-
first
_ lineno (12) - handler= (12)
- hash (24)
- header (12)
-
import
_ methods (4) - inspect (24)
-
instance
_ eval (24) -
instance
_ method (12) -
instance
_ methods (12) - invkind (12)
-
json
_ create (12) - label (12)
-
last
_ match (24) - match (24)
- method (36)
-
method
_ added (12) -
method
_ defined? (12) -
method
_ id (12) -
method
_ missing (12) -
method
_ removed (12) -
method
_ undefined (12) - methods (12)
-
module
_ exec (12) -
module
_ function (36) - name (24)
- new (26)
- of (22)
-
original
_ name (24) - owner (24)
- parameters (31)
- path (12)
- private (48)
-
private
_ class _ method (24) -
private
_ instance _ methods (12) -
private
_ method _ defined? (12) -
protected
_ method _ defined? (12) -
psych
_ yaml _ as (4) - public (12)
-
public
_ class _ method (24) -
public
_ instance _ method (12) -
public
_ method (12) -
public
_ method _ defined? (12) - raise (12)
-
rb
_ define _ method (12) -
rb
_ scan _ args (12) - rdoc (12)
-
rdoc
/ parser / c (12) -
rdoc
/ parser / ruby (12) - receiver (12)
-
remove
_ method (12) -
require
_ relative (12) -
respond
_ to? (12) -
respond
_ to _ missing? (12) -
rexml
/ parsers / streamparser (12) -
ruby 1
. 6 feature (12) -
ruby 1
. 8 . 2 feature (12) -
ruby 1
. 8 . 3 feature (12) -
ruby 1
. 8 . 4 feature (12) -
ruby 1
. 9 feature (12) -
ruby2
_ keywords (12) - send (24)
- seplist (12)
-
singleton
_ method (12) -
singleton
_ method _ added (12) -
singleton
_ method _ removed (12) -
singleton
_ method _ undefined (12) -
singleton
_ methods (12) -
source
_ location (36) -
super
_ method (11) -
to
_ a (12) -
to
_ enum (48) -
to
_ json (108) -
to
_ proc (12) -
to
_ s (36) -
to
_ str (12) - unbind (12)
-
undef
_ method (12) -
yaml
_ as (4) - リテラル (12)
- 制御構造 (12)
検索結果
先頭5件
-
Method (44112.0)
-
Object#method によりオブジェクト化され たメソッドオブジェクトのクラスです。
...bject#method によりオブジェクト化され
たメソッドオブジェクトのクラスです。
メソッドの実体(名前でなく)とレシーバの組を封入します。
Proc オブジェクトと違ってコンテキストを保持しません。
=== Proc との差
Method は......、Method は何度も繰り返し生成する
場合に向くと言えます。また内包するコードの大きさという点では
Proc は小規模、Method は大規模コードに向くと言えます。
既存のメソッドを Method オブジェクト化する。
//emlist[例][ruby]{......lled with arg #{arg}"
end
end
m = Foo.new.method(:foo)
p m # => #<Method: Foo#foo>
p m.call(1) # => "foo called with arg 1"
//}
名前のないメソッド(の代わり)が必要なら Proc を使うと良い。
//emlist[例][ruby]{
pr = Proc.new {|arg|
"proc called with arg... -
Method
# super _ method -> Method | nil (36484.0) -
self 内で super を実行した際に実行されるメソッドを Method オブジェ クトにして返します。
... 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 meth......od"
m.super_method # => #<Method: Super#foo>
m.super_method.call # => "superclass method"
//}... -
Method
# inspect -> String (27250.0) -
self を読みやすい文字列として返します。
...します。
以下の形式の文字列を返します。
#<Method: klass1(klass2)#method(arg) foo.rb:2> (形式1)
klass1 は、Method#inspect では、レシーバのクラス名、
UnboundMethod#inspect では、UnboundMethod オブジェクトの生成
元となったクラス/モジ......いるクラス/モジュール名、
method は、メソッド名を表します。
arg は引数を表します。
「foo.rb:2」は Method#source_location を表します。
source_location が nil の場合には付きません。
//emlist[例][ruby]{
module Foo
def foo
"foo"
end
end......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> (形式2)... -
Method
# to _ s -> String (27250.0) -
self を読みやすい文字列として返します。
...します。
以下の形式の文字列を返します。
#<Method: klass1(klass2)#method(arg) foo.rb:2> (形式1)
klass1 は、Method#inspect では、レシーバのクラス名、
UnboundMethod#inspect では、UnboundMethod オブジェクトの生成
元となったクラス/モジ......いるクラス/モジュール名、
method は、メソッド名を表します。
arg は引数を表します。
「foo.rb:2」は Method#source_location を表します。
source_location が nil の場合には付きません。
//emlist[例][ruby]{
module Foo
def foo
"foo"
end
end......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> (形式2)... -
Method
# inspect -> String (27244.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
# to _ s -> String (27244.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
# arity -> Integer (27166.0) -
メソッドが受け付ける引数の数を返します。
...t[例][ruby]{
class C
def u; end
def v(a); end
def w(*a); end
def x(a, b); end
def y(a, b, *c); end
def z(a, b, *c, &d); end
end
c = C.new
p c.method(:u).arity #=> 0
p c.method(:v).arity #=> 1
p c.method(:w).arity #=> -1
p c.met......hod(:x).arity #=> 2
p c.method(:y).arity #=> -3
p c.method(:z).arity #=> -3
s = "xyz"
s.method(:size).arity #=> 0
s.method(:replace).arity #=> 1
s.method(:squeeze).arity #=> -1
s.method(:count).arity #=> -1
//}... -
Method
# parameters -> [object] (27146.0) -
Method オブジェクトの引数の情報を返します。
...Method オブジェクトの引数の情報を返します。
Method オブジェクトが引数を取らなければ空の配列を返します。引数を取る場合は、配列の配列を返し、
各配列の要素は引数の種類に応じた以下のような Symbol と、仮引数の名......須の引数
: :opt
デフォルト値が指定されたオプショナルな引数
: :rest
* で指定された残りすべての引数
: :keyreq
必須のキーワード引数
: :key
デフォルト値が指定されたオプショナルなキーワード引数
: :keyrest
** で指定され......list[例][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... -
Method
# source _ location -> [String , Integer] | nil (27130.0) -
ソースコードのファイル名と行番号を配列で返します。
... ruby で定義されていない(つまりネイティブ
である)場合は nil を返します。
@see Proc#source_location
//emlist[例][ruby]{
# ------- /tmp/foo.rb ---------
class Foo
def foo; end
end
# ----- end of /tmp/foo.rb ----
require '/tmp/foo'
m = Foo.new.method(:foo) # => #<Met......hod: Foo#foo>
m.source_location # => ["/tmp/foo.rb", 2]
method(:puts).source_location # => nil
//}... -
Method
# to _ proc -> Proc (27118.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
# clone -> Method (24241.0) -
自身を複製した Method オブジェクトを作成して返します。
...自身を複製した Method オブジェクトを作成して返します。
//emlist[例][ruby]{
class Foo
def foo
"foo"
end
end
m = Foo.new.method(:foo) # => #<Method: Foo#foo>
m.call # => "foo"
m.clone # => #<Method: Foo#foo>
m.clone.call # => "foo"
//}...