るりまサーチ (Ruby 2.7.0)

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

別のキーワード

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

検索結果

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

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

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

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

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

send, __send__ は、メソッドの呼び出し制限
にかかわらず任意のメソッドを呼び出せます。
d:spec/def#limit も参照してください。

public メソッドだけ呼び出せれば良い場合は
Object#public_send を使う...

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

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

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

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

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

send, __send__ は、メソッドの呼び出し制限
にかかわらず任意のメソッドを呼び出せます。
d:spec/def#limit も参照してください。

public メソッドだけ呼び出せれば良い場合は
Object#public_send を使う...

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

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

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

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

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

//emlist[例][ruby]{
class Mail
def delete(*args)
"(Mail#delete) - delete " + args.join(',')
end
def send(name, *args)
"(Mail#send) -...

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

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

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

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

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

//emlist[例][ruby]{
class Mail
def delete(*args)
"(Mail#delete) - delete " + args.join(',')
end
def send(name, *args)
"(Mail#send) -...

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

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

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

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

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

@param name 文字列かSymbol で指定するメソッド名です。

@param args 呼び出すメソッドに渡す引数です。

@raise ArgumentError name を指定しなかった場合に発生します。

@raise NoMethodError protected メソッドや priv...

絞り込み条件を変える

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

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

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

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

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

@param name 文字列かSymbol で指定するメソッド名です。

@param args 呼び出すメソッドに渡す引数です。

@raise ArgumentError name を指定しなかった場合に発生します。

@raise NoMethodError protected メソッドや priv...

Method (24079.0)

Object#method によりオブジェクト化され たメソッドオブジェクトのクラスです。

Object#method によりオブジェクト化され
たメソッドオブジェクトのクラスです。

メソッドの実体(名前でなく)とレシーバの組を封入します。
Proc オブジェクトと違ってコンテキストを保持しません。

=== Proc との差

Method は取り出しの対象であるメソッドが
なければ作れませんが、Proc は準備なしに作れます。その点から
Proc は使い捨てに向き、Method は何度も繰り返し生成する
場合に向くと言えます。また内包するコードの大きさという点では
Proc は小規模、Method は大規模コードに向くと言えます。


既存のメソッドを Method オブジェク...

Thread::ConditionVariable (24061.0)

スレッドの同期機構の一つである状態変数を実現するクラスです。

スレッドの同期機構の一つである状態変数を実現するクラスです。

以下も ConditionVariable を理解するのに参考になります。

https://ruby-doc.com/docs/ProgrammingRuby/html/tut_threads.html#UF

=== Condition Variable とは

あるスレッド A が排他領域で動いていたとします。スレッド A は現在空いていない
リソースが必要になったので空くまで待つことにしたとします。これはうまくいきません。
なぜなら、スレッド A は排他領域で動いているわけですから、他のスレッドは動くことが
できません。リ...

Module#append_features(module_or_class) -> self (24043.0)

モジュール(あるいはクラス)に self の機能を追加します。

モジュール(あるいはクラス)に self の機能を追加します。

このメソッドは Module#include の実体であり、
include を Ruby で書くと以下のように定義できます。

//emlist[例][ruby]{
def include(*modules)
modules.reverse_each do |mod|
# append_features や included はプライベートメソッドなので
# 直接 mod.append_features(self) などとは書けない
mod.__send__(:append_features, s...

Module#extend_object(obj) -> object (24043.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__...

絞り込み条件を変える

Object#method(name) -> Method (24043.0)

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

オブジェクトのメソッド name をオブジェクト化した
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__, Objec...

Object#singleton_method(name) -> Method (24043.0)

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

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

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

//emlist[][ruby]{
class Demo
def initialize(n)
@iv = n
end
def hello()
"Hello, @iv = #{@iv}"
end
end

k = Demo.new(99)
def k.hi
"Hi, @iv = ...

BasicObject (24025.0)

特殊な用途のために意図的にほとんど何も定義されていないクラスです。 Objectクラスの親にあたります。Ruby 1.9 以降で導入されました。

特殊な用途のために意図的にほとんど何も定義されていないクラスです。
Objectクラスの親にあたります。Ruby 1.9 以降で導入されました。

=== 性質
BasicObject クラスは Object クラスからほとんどのメソッドを取り除いたクラスです。

Object クラスは様々な便利なメソッドや Kernel から受け継いだ関数的メソッド
を多数有しています。
これに対して、 BasicObject クラスはオブジェクトの同一性を識別したりメソッドを呼んだりする
最低限の機能の他は一切の機能を持っていません。

=== 用途
基本的にはほぼすべてのクラスの親は Object と考...

Kernel.#eval(expr) -> object (24025.0)

文字列 expr を Ruby プログラムとして評価してその結果を返しま す。第2引数に Binding オブジェクトを与えた場合、 そのオブジェクトを生成したコンテキストで文字列を評価します。

文字列 expr を Ruby プログラムとして評価してその結果を返しま
す。第2引数に
Binding オブジェクトを与えた場合、
そのオブジェクトを生成したコンテキストで文字列を評価します。

expr の中のローカル変数の扱いはブロックの場合と同じです。すなわち、eval
実行前に補足されていた変数は eval 実行後にブロック外に持ち出せます。

fname と lineno が与えられた場合には、ファイル
fname の行番号 lineno から文字列 expr が書かれているかのように
コンパイルされます。スタックトレースの表示などを差し替えることが
できます。

bind によ...

Kernel.#eval(expr, bind, fname = "(eval)", lineno = 1) -> object (24025.0)

文字列 expr を Ruby プログラムとして評価してその結果を返しま す。第2引数に Binding オブジェクトを与えた場合、 そのオブジェクトを生成したコンテキストで文字列を評価します。

文字列 expr を Ruby プログラムとして評価してその結果を返しま
す。第2引数に
Binding オブジェクトを与えた場合、
そのオブジェクトを生成したコンテキストで文字列を評価します。

expr の中のローカル変数の扱いはブロックの場合と同じです。すなわち、eval
実行前に補足されていた変数は eval 実行後にブロック外に持ち出せます。

fname と lineno が与えられた場合には、ファイル
fname の行番号 lineno から文字列 expr が書かれているかのように
コンパイルされます。スタックトレースの表示などを差し替えることが
できます。

bind によ...

絞り込み条件を変える

Module#ruby2_keywords(method_name, ...) -> nil (24025.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...

Object#initialize_copy(obj) -> object (24025.0)

(拡張ライブラリによる) ユーザ定義クラスのオブジェクトコピーの初期化メソッド。

(拡張ライブラリによる) ユーザ定義クラスのオブジェクトコピーの初期化メソッド。

このメソッドは self を obj の内容で置き換えます。ただ
し、self のインスタンス変数や特異メソッドは変化しません。
Object#clone, Object#dupの内部で使われています。

initialize_copy は、Ruby インタプリタが知り得ない情報をコピーするた
めに使用(定義)されます。例えば C 言語でクラスを実装する場合、情報
をインスタンス変数に保持させない場合がありますが、そういった内部情
報を initialize_copy でコピーするよう定義しておくことで、du...

Object#public_method(name) -> Method (24025.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 ...

Proc#ruby2_keywords -> proc (24025.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`)
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 ...

RubyVM::InstructionSequence.disasm(body) -> String (24025.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...

絞り込み条件を変える

RubyVM::InstructionSequence.disassemble(body) -> String (24025.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...

Symbol (24025.0)

シンボルを表すクラス。シンボルは任意の文字列と一対一に対応するオブジェクトです。

シンボルを表すクラス。シンボルは任意の文字列と一対一に対応するオブジェクトです。

文字列の代わりに用いることもできますが、必ずしも文字列と同じ振る舞いをするわけではありません。
同じ内容のシンボルはかならず同一のオブジェクトです。

シンボルオブジェクトは以下のようなリテラルで得られます。

:symbol
:'symbol'
%s!symbol! # %記法

生成されたシンボルの一覧は Symbol.all_symbols で得られます。
一番目のリテラルでシンボルを表す場合、`:' の後に
は識別子、メソッド名(`!',`?',`=' などの接尾辞を含む)、変数名
(`$'...