るりまサーチ

最速Rubyリファレンスマニュアル検索!
217件ヒット [1-100件を表示] (0.236秒)
トップページ > クエリ:b[x] > クエリ:_builtin[x] > クエリ:send[x]

別のキーワード

  1. _builtin new
  2. _builtin inspect
  3. _builtin []
  4. _builtin to_s
  5. _builtin each

ライブラリ

クラス

モジュール

キーワード

検索結果

<< 1 2 3 > >>

Object#send(name, *args) -> object (29280.0)

オブジェクトのメソッド name を args を引数に して呼び出し、メソッドの実行結果を返します。

...クもそのまま引き渡します。

send
が再定義された場合に備えて別名 __send__ も
用意されており、ライブラリではこちらを使うべきです。また
__send__ は再定義すべきではありません。

send
, __send__ は、メソッドの呼び出し制限...
...public メソッドだけ呼び出せれば良い場合は
Object#public_send を使う方が良いでしょう。

@param name 文字列かSymbol で指定するメソッド名です。
@param args 呼び出すメソッドに渡す引数です。

//emlist[][ruby]{
p -365.send(:abs) #=> 365
p "ruby...
...".send(:sub,/./,"R") #=> "Ruby"


class Foo
def foo() "foo" end
def bar() "bar" end
def baz() "baz" end
end

# 任意のキーとメソッド(の名前)の関係をハッシュに保持しておく
# レシーバの情報がここにはないことに注意
methods = {1 => :foo,
2 => :bar,...

Object#send(name, *args) { .... } -> object (29280.0)

オブジェクトのメソッド name を args を引数に して呼び出し、メソッドの実行結果を返します。

...クもそのまま引き渡します。

send
が再定義された場合に備えて別名 __send__ も
用意されており、ライブラリではこちらを使うべきです。また
__send__ は再定義すべきではありません。

send
, __send__ は、メソッドの呼び出し制限...
...public メソッドだけ呼び出せれば良い場合は
Object#public_send を使う方が良いでしょう。

@param name 文字列かSymbol で指定するメソッド名です。
@param args 呼び出すメソッドに渡す引数です。

//emlist[][ruby]{
p -365.send(:abs) #=> 365
p "ruby...
...".send(:sub,/./,"R") #=> "Ruby"


class Foo
def foo() "foo" end
def bar() "bar" end
def baz() "baz" end
end

# 任意のキーとメソッド(の名前)の関係をハッシュに保持しておく
# レシーバの情報がここにはないことに注意
methods = {1 => :foo,
2 => :bar,...

Object#public_send(name, *args) -> object (20226.0)

オブジェクトの public メソッド name を args を引数にして呼び出し、メソッ ドの実行結果を返します。

...の public メソッド name を args を引数にして呼び出し、メソッ
ドの実行結果を返します。

ブロック付きで呼ばれたときはブロックもそのまま引き渡します。

//emlist[][ruby]{
1.public_send(:+, 2) # => 3
//}

@param name 文字列かSymbol で指...
...しなかった場合に発生します。

@raise NoMethodError protected メソッドや private メソッドに対して実行
した場合に発生します。

//emlist[][ruby]{
1.public_send(:puts, "hello") # => NoMethodError
//}

@see BasicObject#__send__, Object#send...

Object#public_send(name, *args) { .... } -> object (20226.0)

オブジェクトの public メソッド name を args を引数にして呼び出し、メソッ ドの実行結果を返します。

...の public メソッド name を args を引数にして呼び出し、メソッ
ドの実行結果を返します。

ブロック付きで呼ばれたときはブロックもそのまま引き渡します。

//emlist[][ruby]{
1.public_send(:+, 2) # => 3
//}

@param name 文字列かSymbol で指...
...しなかった場合に発生します。

@raise NoMethodError protected メソッドや private メソッドに対して実行
した場合に発生します。

//emlist[][ruby]{
1.public_send(:puts, "hello") # => NoMethodError
//}

@see BasicObject#__send__, Object#send...

BasicObject#__send__(name, *args) -> object (17238.0)

オブジェクトのメソッド name を args を引数にして呼び出し、メソッドの結果を返します。

...メソッドの名前。 Symbol または文字列で指定します。
@param args メソッドに渡す任意個の引数

//emlist[例][ruby]{
class Mail
def delete(*args)
"(Mail#delete) - delete " + args.join(',')
end
def send(name, *args)
"(Mail#send) - #{name} #{args.join(',')}"...
...end
end
mail = Mail.new
mail.send :delete, "gentle", "readers" # => "(Mail#send) - delete gentle,readers"
mail.__send__ :delete, "gentle", "readers" # => "(Mail#delete) - delete gentle,readers"
//}

@see Object#send...

絞り込み条件を変える

BasicObject#__send__(name, *args) { .... } -> object (17238.0)

オブジェクトのメソッド name を args を引数にして呼び出し、メソッドの結果を返します。

...メソッドの名前。 Symbol または文字列で指定します。
@param args メソッドに渡す任意個の引数

//emlist[例][ruby]{
class Mail
def delete(*args)
"(Mail#delete) - delete " + args.join(',')
end
def send(name, *args)
"(Mail#send) - #{name} #{args.join(',')}"...
...end
end
mail = Mail.new
mail.send :delete, "gentle", "readers" # => "(Mail#send) - delete gentle,readers"
mail.__send__ :delete, "gentle", "readers" # => "(Mail#delete) - delete gentle,readers"
//}

@see Object#send...

Module#extend_object(obj) -> object (14312.0)

Object#extend の実体です。オブジェクトにモジュールの機能を追加します。

...Object#extend の実体です。オブジェクトにモジュールの機能を追加します。

Object#extend は、Ruby で書くと以下のように定義できます。

//emlist[例][ruby]{
def extend(*modules)
modules.reverse_each do |mod|
# extend_object や extended はプライ...
...
# 直接 mod.extend_object(self) などとは書けない
mod.__send__(:extend_object, self)
mod.__send__(:extended, self)
end
end
//}

extend_object のデフォルトの実装では、self に定義されて
いるインスタンスメソッドを obj の特異メソッドとし...
...て追加します。

@param obj self の機能を追加するオブジェクトを指定します。

@return obj で指定されたオブジェクトを返します。

@see Module#extended...

Module#ruby2_keywords(method_name, ...) -> nil (14106.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...
...s 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 only
for backwards compatibility...
...in Ruby versions
b
efore 2.7, check that 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...

Object#public_method(name) -> Method (14106.0)

オブジェクトの public メソッド name をオブジェクト化した Method オブジェクトを返します。

...オブジェクトの public メソッド name をオブジェクト化した
Method オブジェクトを返します。

@param name メソッド名を Symbol または String で指定します。
@raise NameError 定義されていないメソッド名や、
protected メソッド名、...
...vate メソッド名を引数として与えると発生します。

//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...

Proc#ruby2_keywords -> proc (14106.0)

Marks the proc as passing keywords through a normal argument splat. This should only be called on procs that accept an argument splat (`*args`) but not explicit keywords or a keyword splat. It marks the proc such that if the proc 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 proc to other methods.

...Marks the proc as passing keywords through a normal argument splat. This
should only be called on procs that accept an argument splat (`*args`)
b
ut not explicit keywords or a keyword splat. It marks the proc such
that if the proc is called with keyword arguments, the final hash
argument is marked...
...rds will
b
e passed through the proc to other methods.

This should only be used for procs 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 only
for backwards compatibility....
...t in Ruby versions
b
efore 2.7, check that the proc responds to this method before calling
it. Also, be aware that if this method is removed, the behavior of the
proc will change so that it does not pass through keywords.

//emlist[][ruby]{
module Mod
foo = ->(meth, *args, &block) do
send
(:"do_...

絞り込み条件を変える

RubyVM::InstructionSequence.disassemble(body) -> String (14106.0)

引数 body で指定したオブジェクトから作成した RubyVM::InstructionSequence オブジェクトを人間が読める形式の文字 列に変換して返します。

...引数 body で指定したオブジェクトから作成した
RubyVM::InstructionSequence オブジェクトを人間が読める形式の文字
列に変換して返します。

@param body Proc、Method オブジェクトを指定します。

例1:Proc オブジェクトを指定した場合...
...# /tmp/proc.rb
p = proc { num = 1 + 2 }
puts RubyVM::InstructionSequence.disasm(p)

出力:

== disasm: <RubyVM::InstructionSequence:block in <main>@/tmp/proc.rb>===
== catch table
| catch type: redo st: 0000 ed: 0012 sp: 0000 cont: 0000
| catch type: next st: 0000 ed: 0012 sp: 00...
...------------------------------------------
local table (size: 2, argc: 0 [opts: 0, rest: -1, post: 0, block: -1] s1)
[ 2] num
0000 trace 1 ( 1)
0002 putobject 1
0004 putobject 2
0006 opt_plus <ic:1>
0008 d...
<< 1 2 3 > >>