るりまサーチ

最速Rubyリファレンスマニュアル検索!
264件ヒット [1-100件を表示] (0.131秒)

別のキーワード

  1. csv instance
  2. prime instance
  3. syslog instance
  4. _builtin instance_eval
  5. basicobject instance_eval

ライブラリ

クラス

検索結果

<< 1 2 3 > >>

Module#instance_method(name) -> UnboundMethod (24250.0)

self のインスタンスメソッド name をオブジェクト化した UnboundMethod を返します。

...ソッド name をオブジェクト化した UnboundMethod を返します。

@param name メソッド名を Symbol または String で指定します。

@raise NameError self に存在しないメソッドを指定した場合に発生します。

@see Module#public_instance_method, Object#met...
...ass 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!
//}...

Module#public_instance_method(name) -> UnboundMethod (12220.0)

self の public インスタンスメソッド name をオブジェクト化した UnboundMethod を返します。

...タンスメソッド 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#instance_methods(inherited_too = true) -> [Symbol] (12201.0)

そのモジュールで定義されている public および protected メソッド名 の一覧を配列で返します。

...ッド名
の一覧を配列で返します。

@param inherited_too false を指定するとそのモジュールで定義されているメソッドのみ返します。

@see Object#methods

//emlist[例1][ruby]{
class Foo
private; def private_foo() end
protected; def protected_foo() end...
...ドの一覧を得る
p Foo.instance_methods(false)
p Foo.public_instance_methods(false)
p Foo.private_instance_methods(false)
p Foo.protected_instance_methods(false)

class Bar < Foo
end
//}

実行結果

[:protected_foo, :public_foo]
[:public_foo]
[:private_foo]
[:protected_fo...
...o]

//emlist[例2][ruby]{
class Bar
private; def private_foo() end
protected; def protected_foo() end
public; def public_foo() end
end

# あるクラスのインスタンスメソッドの一覧を得る。
# 親のクラスのインスタンスメソッドも含めるため true...

Module#private_instance_methods(inherited_too = true) -> [Symbol] (12201.0)

そのモジュールで定義されている private メソッド名 の一覧を配列で返します。

...ate メソッド名
の一覧を配列で返します。

@param inherited_too false を指定するとそのモジュールで定義されているメソッドのみ返します。

@see Object#private_methods, Module#instance_methods

//emlist[例][ruby]{
module Foo
def foo; end
private def ba...
...r; end
end

module Bar
include Foo

def baz; end
private def qux; end
end

Bar.private_instance_methods # => [:qux, :bar]
Bar.private_instance_methods(false) # => [:qux]
//}...

Module#protected_instance_methods(inherited_too = true) -> [Symbol] (12201.0)

そのモジュールで定義されている protected メソッド名 の一覧を配列で返します。

...そのモジュールで定義されている protected メソッド名
の一覧を配列で返します。

@param inherited_too false を指定するとそのモジュールで定義されているメソッドのみ返します。


@see Object#protected_methods, Module#instance_methods...

絞り込み条件を変える

Module#public_instance_methods(inherited_too = true) -> [Symbol] (12201.0)

そのモジュールで定義されている public メソッド名 の一覧を配列で返します。

...そのモジュールで定義されている public メソッド名
の一覧を配列で返します。

@param inherited_too false を指定するとそのモジュールで定義されているメソッドのみ返します。


@see Object#public_methods, Module#instance_methods...

UnboundMethod#arity -> Integer (6191.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
/...

UnboundMethod#name -> Symbol (6119.0)

このメソッドの名前を返します。

...このメソッドの名前を返します。

//emlist[例][ruby]{
a
= String.instance_method(:size)
a
.name # => :size
//}...

UnboundMethod#source_location -> [String, Integer] | nil (6113.0)

ソースコードのファイル名と行番号を配列で返します。

...nil を返します。

//emlist[例][ruby]{
require 'time'

Time.instance_method(:zone).source_location # => nil
Time.instance_method(:httpdate).source_location # => ["/Users/user/.rbenv/versions/2.4.3/lib/ruby/2.4.0/time.rb", 654]
//}

@see Proc#source_location, Method#source_location...
<< 1 2 3 > >>