るりまサーチ (Ruby 3.2)

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

別のキーワード

  1. _builtin *
  2. matrix *
  3. array *
  4. vector *
  5. bigdecimal *

クラス

モジュール

検索結果

Data#with(**kwargs) -> Data (54649.0)

self をコピーしたオブジェクトを返します。

self をコピーしたオブジェクトを返します。

値オブジェクトのメンバのオブジェクトはコピーされません。つまり参照しているオブジェクトが変わらない「浅い(shallow)」コピーを行います。

キーワード引数が指定された場合、引数に対応するメンバには引数の値が設定されます。存在しないメンバを指定した場合はエラーとなります。

@param kwargs コピーされたオブジェクトに設定されるメンバの値を指定します。

@raise ArgumentError 存在しないメンバを指定した場合に発生します。

//emlist[例][ruby]{
Dog = Data.define(:name,...

Symbol#start_with?(*prefixes) -> bool (18739.0)

self の先頭が prefixes のいずれかであるとき true を返します。

self の先頭が prefixes のいずれかであるとき true を返します。

(self.to_s.start_with?と同じです。)

@param prefixes パターンを表す文字列または正規表現 (のリスト)

@see Symbol#end_with?

@see String#start_with?

//emlist[][ruby]{
:hello.start_with?("hell") #=> true
:hello.start_with?(/H/i) #=> true

# returns true i...

String#start_with?(*prefixes) -> bool (18721.0)

self の先頭が prefixes のいずれかであるとき true を返します。

self の先頭が prefixes のいずれかであるとき true を返します。

@param prefixes パターンを表す文字列または正規表現 (のリスト)

//emlist[例][ruby]{
"string".start_with?("str") # => true
"string".start_with?("ing") # => false
"string".start_with?("ing", "str") # => true
"string".start_with?(/\w/) # => true
"strin...

Symbol#end_with?(*suffixes) -> bool (18721.0)

self の末尾が suffixes のいずれかであるとき true を返します。

self の末尾が suffixes のいずれかであるとき true を返します。

(self.to_s.end_with?と同じです。)

@param suffixes パターンを表す文字列 (のリスト)

@see Symbol#start_with?

@see String#end_with?

//emlist[][ruby]{
:hello.end_with?("ello") #=> true

# returns true if one of the +suffixes+ matches.
:hello.end_with?("heaven", "...

Enumerable#each_with_index(*args) -> Enumerator (18706.0)

要素とそのインデックスをブロックに渡して繰り返します。

要素とそのインデックスをブロックに渡して繰り返します。

ブロックを省略した場合は、
要素とそのインデックスを繰り返すような
Enumerator を返します。

Enumerator#with_index は offset 引数を受け取りますが、
each_with_index は受け取りません (引数はイテレータメソッドにそのまま渡されます)。

@param args イテレータメソッド (each など) にそのまま渡されます。

//emlist[例][ruby]{
[5, 10, 15].each_with_index do |n, idx|
p [n, idx]
end
#...

絞り込み条件を変える

Enumerable#each_with_index(*args) {|item, index| ... } -> self (18706.0)

要素とそのインデックスをブロックに渡して繰り返します。

要素とそのインデックスをブロックに渡して繰り返します。

ブロックを省略した場合は、
要素とそのインデックスを繰り返すような
Enumerator を返します。

Enumerator#with_index は offset 引数を受け取りますが、
each_with_index は受け取りません (引数はイテレータメソッドにそのまま渡されます)。

@param args イテレータメソッド (each など) にそのまま渡されます。

//emlist[例][ruby]{
[5, 10, 15].each_with_index do |n, idx|
p [n, idx]
end
#...

Enumerator#with_index(offset = 0) {|(*args), idx| ... } -> object (18688.0)

生成時のパラメータに従って、要素にインデックスを添えて繰り返します。 インデックスは offset から始まります。

生成時のパラメータに従って、要素にインデックスを添えて繰り返します。
インデックスは offset から始まります。

ブロックを指定した場合の戻り値は生成時に指定したレシーバ自身です。

//emlist[例][ruby]{
str = "xyz"

enum = Enumerator.new {|y| str.each_byte {|b| y << b }}
enum.with_index {|byte, idx| p [byte, idx] }
# => [120, 0]
# [121, 1]
# [122, 2]

require "stringi...

Enumerator#with_object(obj) {|(*args), memo_obj| ... } -> object (18688.0)

繰り返しの各要素に obj を添えてブロックを繰り返し、obj を返り値として返します。

繰り返しの各要素に obj を添えてブロックを繰り返し、obj を返り値として返します。

obj には任意のオブジェクトを渡すことができます。

ブロックが渡されなかった場合は、上で説明した繰り返しを実行し、
最後に obj を返す Enumerator を返します。

//emlist[例][ruby]{
# 0,1,2 と呼びだす enumeratorを作る
to_three = Enumerator.new do |y|
3.times do |x|
y << x
end
end

to_three_with_string = to_three.with_object...

String#end_with?(*strs) -> bool (18685.0)

self の末尾が strs のいずれかであるとき true を返します。

self の末尾が strs のいずれかであるとき true を返します。

@param strs パターンを表す文字列 (のリスト)

//emlist[例][ruby]{
"string".end_with?("ing") # => true
"string".end_with?("str") # => false
"string".end_with?("str", "ing") # => true
//}

@see String#start_with?
@see String#delete_suffix, String#delete_s...

Enumerable#each_with_object(obj) {|(*args), memo_obj| ... } -> object (18670.0)

与えられた任意のオブジェクトと要素をブロックに渡し繰り返し、最初に与えられたオブジェクトを返します。

与えられた任意のオブジェクトと要素をブロックに渡し繰り返し、最初に与えられたオブジェクトを返します。

ブロックを省略した場合は Enumerator を返します。

@param obj 任意のオブジェクトを指定します。

//emlist[例][ruby]{
evens = (1..10).each_with_object([]) {|i, a| a << i*2 }
# => [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]
//}

@see Enumerator#with_object

絞り込み条件を変える

Enumerator::Lazy#with_index(offset = 0) {|(*args), idx| ... } -> Enumerator::Lazy (18652.0)

生成時のパラメータに従って、要素にインデックスを添えて繰り返します。 インデックスは offset から始まります。

生成時のパラメータに従って、要素にインデックスを添えて繰り返します。
インデックスは offset から始まります。

ブロックを指定した場合の戻り値は生成時に指定したレシーバ自身です。

//emlist[][ruby]{
("a"..).lazy.with_index(1) { |it, index| puts "#{index}:#{it}" }.take(3).force
# => 1:a
# 2:b
# 3:c
//}

@see Enumerator#with_index

Enumerable#each_with_object(obj) -> Enumerator (18370.0)

与えられた任意のオブジェクトと要素をブロックに渡し繰り返し、最初に与えられたオブジェクトを返します。

与えられた任意のオブジェクトと要素をブロックに渡し繰り返し、最初に与えられたオブジェクトを返します。

ブロックを省略した場合は Enumerator を返します。

@param obj 任意のオブジェクトを指定します。

//emlist[例][ruby]{
evens = (1..10).each_with_object([]) {|i, a| a << i*2 }
# => [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]
//}

@see Enumerator#with_object

Time#strftime(format) -> String (1054.0)

時刻を format 文字列に従って文字列に変換した結果を返します。

時刻を format 文字列に従って文字列に変換した結果を返します。

@param format フォーマット文字列を指定します。使用できるものは 以下の通りです。

* %A: 曜日の名称(Sunday, Monday ... )
* %a: 曜日の省略名(Sun, Mon ... )
* %B: 月の名称(January, February ... )
* %b: 月の省略名(Jan, Feb ... )
* %C: 世紀 (2009年であれば 20)
* %c: 日付と時刻 (%a %b %e %T %Y)
* %D: 日付 (%m/%d/%y)
* ...

Method#===(*args) -> object (364.0)

メソッドオブジェクトに封入されているメソッドを起動します。

メソッドオブジェクトに封入されているメソッドを起動します。

引数やブロックはそのままメソッドに渡されます。

self[] の形の呼び出しは通常のメソッド呼び出しに見た目を
近付けるためだけに用意されたもので、Array#[]のような
他の [] メソッドとの意味的な関連性はありません。


@param args self に渡される引数。

@see UnboundMethod#bind_call

//emlist[例][ruby]{
class Foo
def foo(arg)
"foo called with arg #{arg}"
end
end

m = Fo...

Method#[](*args) -> object (364.0)

メソッドオブジェクトに封入されているメソッドを起動します。

メソッドオブジェクトに封入されているメソッドを起動します。

引数やブロックはそのままメソッドに渡されます。

self[] の形の呼び出しは通常のメソッド呼び出しに見た目を
近付けるためだけに用意されたもので、Array#[]のような
他の [] メソッドとの意味的な関連性はありません。


@param args self に渡される引数。

@see UnboundMethod#bind_call

//emlist[例][ruby]{
class Foo
def foo(arg)
"foo called with arg #{arg}"
end
end

m = Fo...

絞り込み条件を変える

Method#call(*args) -> object (364.0)

メソッドオブジェクトに封入されているメソッドを起動します。

メソッドオブジェクトに封入されているメソッドを起動します。

引数やブロックはそのままメソッドに渡されます。

self[] の形の呼び出しは通常のメソッド呼び出しに見た目を
近付けるためだけに用意されたもので、Array#[]のような
他の [] メソッドとの意味的な関連性はありません。


@param args self に渡される引数。

@see UnboundMethod#bind_call

//emlist[例][ruby]{
class Foo
def foo(arg)
"foo called with arg #{arg}"
end
end

m = Fo...

Method#call(*args) { ... } -> object (364.0)

メソッドオブジェクトに封入されているメソッドを起動します。

メソッドオブジェクトに封入されているメソッドを起動します。

引数やブロックはそのままメソッドに渡されます。

self[] の形の呼び出しは通常のメソッド呼び出しに見た目を
近付けるためだけに用意されたもので、Array#[]のような
他の [] メソッドとの意味的な関連性はありません。


@param args self に渡される引数。

@see UnboundMethod#bind_call

//emlist[例][ruby]{
class Foo
def foo(arg)
"foo called with arg #{arg}"
end
end

m = Fo...

Refinement#import_methods(*modules) -> self (346.0)

モジュールからメソッドをインポートします。

モジュールからメソッドをインポートします。

Module#includeと違って、import_methods はメソッドをコピーして
refinement に追加して、refinementでインポートしたメソッドを有効化します。

メソッドをコピーするため、Rubyコードで定義されたメソッドだけしか
インポートできないことに注意してください。

//emlist[][ruby]{
module StrUtils
def indent(level)
' ' * level + self
end
end

module M
refine String do
imp...

Enumerable#to_h(*args) -> Hash (328.0)

self を [key, value] のペアの配列として解析した結果を Hash にして 返します。

self を [key, value] のペアの配列として解析した結果を Hash にして
返します。

@param args each の呼び出し時に引数として渡されます。

//emlist[例][ruby]{
%i[hello world].each_with_index.to_h # => {:hello => 0, :world => 1}
//}

ブロックを指定すると各要素でブロックを呼び出し、
その結果をペアとして使います。

//emlist[ブロック付きの例][ruby]{
(1..5).to_h {|x| [x, x ** 2]} # => {1=>1, 2=>4, ...

Enumerable#to_h(*args) { ... } -> Hash (328.0)

self を [key, value] のペアの配列として解析した結果を Hash にして 返します。

self を [key, value] のペアの配列として解析した結果を Hash にして
返します。

@param args each の呼び出し時に引数として渡されます。

//emlist[例][ruby]{
%i[hello world].each_with_index.to_h # => {:hello => 0, :world => 1}
//}

ブロックを指定すると各要素でブロックを呼び出し、
その結果をペアとして使います。

//emlist[ブロック付きの例][ruby]{
(1..5).to_h {|x| [x, x ** 2]} # => {1=>1, 2=>4, ...

絞り込み条件を変える

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

Proc#ruby2_keywords -> proc (160.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 ...

Enumerable#max_by -> Enumerator (100.0)

各要素を順番にブロックに渡して実行し、 その評価結果を <=> で比較して、 最大であった値に対応する元の要素、もしくは最大の n 要素が降順で入った配列を返します。

各要素を順番にブロックに渡して実行し、
その評価結果を <=> で比較して、
最大であった値に対応する元の要素、もしくは最大の n 要素が降順で入った配列を返します。

引数を指定しない形式では要素が存在しなければ nil を返します。
引数を指定する形式では、空の配列を返します。
該当する要素が複数存在する場合、どの要素を返すかは不定です。

Enumerable#max と Enumerable#max_by の
違いは Enumerable#sort と Enumerable#sort_by の違いと同じです。

ブロックを省略した場合は Enumerator を返します。

@par...

Enumerable#max_by {|item| ... } -> object | nil (100.0)

各要素を順番にブロックに渡して実行し、 その評価結果を <=> で比較して、 最大であった値に対応する元の要素、もしくは最大の n 要素が降順で入った配列を返します。

各要素を順番にブロックに渡して実行し、
その評価結果を <=> で比較して、
最大であった値に対応する元の要素、もしくは最大の n 要素が降順で入った配列を返します。

引数を指定しない形式では要素が存在しなければ nil を返します。
引数を指定する形式では、空の配列を返します。
該当する要素が複数存在する場合、どの要素を返すかは不定です。

Enumerable#max と Enumerable#max_by の
違いは Enumerable#sort と Enumerable#sort_by の違いと同じです。

ブロックを省略した場合は Enumerator を返します。

@par...

Enumerable#max_by(n) -> Enumerator (100.0)

各要素を順番にブロックに渡して実行し、 その評価結果を <=> で比較して、 最大であった値に対応する元の要素、もしくは最大の n 要素が降順で入った配列を返します。

各要素を順番にブロックに渡して実行し、
その評価結果を <=> で比較して、
最大であった値に対応する元の要素、もしくは最大の n 要素が降順で入った配列を返します。

引数を指定しない形式では要素が存在しなければ nil を返します。
引数を指定する形式では、空の配列を返します。
該当する要素が複数存在する場合、どの要素を返すかは不定です。

Enumerable#max と Enumerable#max_by の
違いは Enumerable#sort と Enumerable#sort_by の違いと同じです。

ブロックを省略した場合は Enumerator を返します。

@par...

絞り込み条件を変える

Enumerable#max_by(n) {|item| ... } -> Array (100.0)

各要素を順番にブロックに渡して実行し、 その評価結果を <=> で比較して、 最大であった値に対応する元の要素、もしくは最大の n 要素が降順で入った配列を返します。

各要素を順番にブロックに渡して実行し、
その評価結果を <=> で比較して、
最大であった値に対応する元の要素、もしくは最大の n 要素が降順で入った配列を返します。

引数を指定しない形式では要素が存在しなければ nil を返します。
引数を指定する形式では、空の配列を返します。
該当する要素が複数存在する場合、どの要素を返すかは不定です。

Enumerable#max と Enumerable#max_by の
違いは Enumerable#sort と Enumerable#sort_by の違いと同じです。

ブロックを省略した場合は Enumerator を返します。

@par...

Enumerable#chunk {|elt| ... } -> Enumerator (64.0)

要素を前から順にブロックで評価し、その結果によって 要素をチャンクに分けた(グループ化した)要素を持つ Enumerator を返します。

要素を前から順にブロックで評価し、その結果によって
要素をチャンクに分けた(グループ化した)要素を持つ
Enumerator を返します。

ブロックの評価値が同じ値が続くものを一つのチャンクとして
取り扱います。すなわち、ブロックの評価値が一つ前と
異なる所でチャンクが区切られます。

返り値の Enumerator は各チャンクのブロック評価値と
各チャンクの要素を持つ配列のペアを各要素とします。
そのため、eachだと以下のようになります。

//emlist[][ruby]{
enum.chunk {|elt| key }.each {|key, ary| do_something ...

Hash#transform_values -> Enumerator (46.0)

すべての値に対してブロックを呼び出した結果で置き換えたハッシュを返します。 キーは変化しません。

...{ a: 2, b: 5, c: 10 }
h.transform_values(&:to_s) #=> { a: "1", b: "2", c: "3" }
h.transform_values.with_index {|v, i| "#{v}.#{i}" }
#=> { a: "1.0", b: "2.1", c: "3.2" }
//}

@see Hash#transform_values!
@see Hash#transform_keys
@see Hash#transform_keys!...

Hash#transform_values {|value| ... } -> Hash (46.0)

すべての値に対してブロックを呼び出した結果で置き換えたハッシュを返します。 キーは変化しません。

...{ a: 2, b: 5, c: 10 }
h.transform_values(&:to_s) #=> { a: "1", b: "2", c: "3" }
h.transform_values.with_index {|v, i| "#{v}.#{i}" }
#=> { a: "1.0", b: "2.1", c: "3.2" }
//}

@see Hash#transform_values!
@see Hash#transform_keys
@see Hash#transform_keys!...

Hash#transform_values! -> Enumerator (46.0)

すべての値に対してブロックを呼び出した結果でハッシュの値を変更します。 キーは変化しません。

すべての値に対してブロックを呼び出した結果でハッシュの値を変更します。
キーは変化しません。

@return transform_values! は常に self を返します。
ブロックが与えられなかった場合は、Enumerator オブジェクトを
返します。

//emlist[例][ruby]{
h = { a: 1, b: 2, c: 3 }
h.transform_values! {|v| v * v + 1 } #=> { a: 2, b: 5, c: 10 }
h.transform_values!(&:to_s) #=> ...

絞り込み条件を変える

Hash#transform_values! {|value| ... } -> self (46.0)

すべての値に対してブロックを呼び出した結果でハッシュの値を変更します。 キーは変化しません。

すべての値に対してブロックを呼び出した結果でハッシュの値を変更します。
キーは変化しません。

@return transform_values! は常に self を返します。
ブロックが与えられなかった場合は、Enumerator オブジェクトを
返します。

//emlist[例][ruby]{
h = { a: 1, b: 2, c: 3 }
h.transform_values! {|v| v * v + 1 } #=> { a: 2, b: 5, c: 10 }
h.transform_values!(&:to_s) #=> ...