別のキーワード
種類
- インスタンスメソッド (144)
- 関数 (36)
- 文書 (30)
- クラス (12)
ライブラリ
- ビルトイン (156)
クラス
- Method (12)
- Module (60)
- Object (24)
- UnboundMethod (48)
キーワード
-
NEWS for Ruby 2
. 7 . 0 (6) - UnboundMethod (12)
- arity (12)
- bind (12)
-
define
_ method (24) -
instance
_ methods (12) -
method
_ added (12) -
original
_ name (12) - owner (12)
- parameters (12)
-
public
_ method (12) -
rb
_ class _ instance _ methods (12) -
rb
_ class _ private _ instance _ methods (12) -
rb
_ class _ protected _ instance _ methods (12) -
ruby 1
. 6 feature (12) -
ruby 1
. 8 . 4 feature (12) -
singleton
_ method (12)
検索結果
先頭5件
- Module
# instance _ method(name) -> UnboundMethod - VALUE rb
_ class _ instance _ methods(int argc , VALUE *argv , VALUE mod) - VALUE rb
_ class _ private _ instance _ methods(int argc , VALUE *argv , VALUE mod) - VALUE rb
_ class _ protected _ instance _ methods(int argc , VALUE *argv , VALUE mod) - Module
# instance _ methods(inherited _ too = true) -> [Symbol]
-
Module
# instance _ method(name) -> UnboundMethod (18137.0) -
self のインスタンスメソッド name をオブジェクト化した UnboundMethod を返します。
...#public_instance_method, Object#method
//emlist[例][ruby]{
class Interpreter
def do_a() print "there, "; end
def do_d() print "Hello "; end
def do_e() 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 }
end
end
interpreter = Interpreter.new
interpreter.interpret('dave')
# => Hello there, Dave!
//}... -
VALUE rb
_ class _ instance _ methods(int argc , VALUE *argv , VALUE mod) (12200.0) -
Module#instance_methods の実体。 モジュール mod に定義されている public メソッド名の リストを文字列の配列で返します。
...Module#instance_methods の実体。
モジュール mod に定義されている public メソッド名の
リストを文字列の配列で返します。... -
VALUE rb
_ class _ private _ instance _ methods(int argc , VALUE *argv , VALUE mod) (12200.0) -
Module#private_instance_methods の実体。 モジュール mod に定義されている private メソッド名の リストを文字列の配列で返します。
...Module#private_instance_methods の実体。
モジュール mod に定義されている private メソッド名の
リストを文字列の配列で返します。... -
VALUE rb
_ class _ protected _ instance _ methods(int argc , VALUE *argv , VALUE mod) (12200.0) -
Module#protected_instance_methods の実体。 モジュール mod に定義されている protected メソッド名の リストを文字列の配列で返します。
...Module#protected_instance_methods の実体。
モジュール mod に定義されている protected メソッド名の
リストを文字列の配列で返します。... -
Module
# instance _ methods(inherited _ too = true) -> [Symbol] (6118.0) -
そのモジュールで定義されている public および protected メソッド名 の一覧を配列で返します。
...by]{
class Foo
private; def private_foo() end
protected; def protected_foo() end
public; def public_foo() end
end
# あるクラスのインスタンスメソッドの一覧を得る
p Foo.instance_methods(false)
p Foo.public_instance_methods(false)
p Foo.private_instance_methods(fa......lse)
p Foo.protected_instance_methods(false)
class Bar < Foo
end
//}
実行結果
[:protected_foo, :public_foo]
[:public_foo]
[:private_foo]
[:protected_foo]
//emlist[例2][ruby]{
class Bar
private; def private_foo() end
protected; def protected_foo() end
public;......ar.instance_methods(true) - Object.instance_methods(true)
p Bar.public_instance_methods(true) - Object.public_instance_methods(true)
p Bar.private_instance_methods(true) - Object.private_instance_methods(true)
p Bar.protected_instance_methods(true) - Object.protected_instance_methods(... -
ruby 1
. 6 feature (246.0) -
ruby 1.6 feature ruby version 1.6 は安定版です。この版での変更はバグ修正がメイン になります。
...module_eval>)) のブロック内で定数やクラス変数のスコープが
変わることはなくなりました。((<ruby-dev:17876>))
class Foo
FOO = 1
@@foo = 1
end
FOO = 2
@@foo = 2
Foo.module_eval { p FOO, @@foo }
=......列を返すようになった
: 2002-03-08 class variable
((<ruby-talk:35122>))
class C
class << self
def test
@@cv = 5
p @@cv
end
end
test
end
=> -:5:in `test': uninitialized class variable @@cv in C (NameError)
fr......ていました。((<ruby-dev:14942>))
Module.constants.each {|c|
c = eval c
if c.instance_of?(Class)
p c
c.instance_methods.each {|m|
c.module_eval "undef #{m};"
}
c.module_eval {undef initialize}
e... -
UnboundMethod
# owner -> Class | Module (135.0) -
このメソッドが定義されている class か module を返します。
...このメソッドが定義されている class か module を返します。
//emlist[例][ruby]{
Integer.instance_method(:to_s).owner # => Integer
Integer.instance_method(:to_c).owner # => Numeric
Integer.instance_method(:hash).owner # => Kernel
//}... -
UnboundMethod
# arity -> Integer (66.0) -
メソッドが受け付ける引数の数を返します。
...{
class C
def one; end
def two(a); end
def three(*a); end
def four(a, b); end
def five(a, b, *c); end
def six(a, b, *c, &d); end
end
p C.instance_method(:one).arity #=> 0
p C.instance_method(:two).arity #=> 1
p C.instance_method(:three).arity #=> -1
p C.instance_method(......:four).arity #=> 2
p C.instance_method(:five).arity #=> -3
p C.instance_method(:six).arity #=> -3
String.instance_method(:size).arity #=> 0
String.instance_method(:replace).arity #=> 1
String.instance_method(:squeeze).arity #=> -1
String.instance_method(:count).arity #=> -1... -
NEWS for Ruby 2
. 7 . 0 (54.0) -
NEWS for Ruby 2.7.0 このドキュメントは前回リリース以降のバグ修正を除くユーザーに影響のある機能の変更のリストです。
...ted です。 15575
この警告は「-W:no-deprecated」オプションで止められます。
//emlist{
def foo
class << Object.new
yield #=> warning: `yield' in class syntax will not be supported from Ruby 3.0. 15575
end
end
foo { p :ok }
//}
* 引数を転送する記法「(...)......by 3.0 では verbose モードでなくても表示され、Ruby 3.2 で削除される
予定です。 16131
* Object#methodとModule#instance_methodがrefinementsを考慮するようになりました。 15373
=== コマンドラインオプション
==== 警告オプション
カテ......sday?) #=> next Tuesday
//}
//emlist[Enumerator::Lazy#eager][ruby]{
a = %w(foo bar baz)
e = a.lazy.map {|x| x.upcase }.map {|x| x + "!" }.eager
p e.class #=> Enumerator
p e.map {|x| x + "?" } #=> ["FOO!?", "BAR!?", "BAZ!?"]
//}
//emlist[Enumerator::Lazy#with_index][ruby]{
("a"..).lazy...