Skip to content

Commit

Permalink
Merge pull request #2619 from pofkuma/fix_explanation_about_no_block
Browse files Browse the repository at this point in the history
ブロックが省略された場合の説明を修正
  • Loading branch information
znz committed Dec 1, 2021
2 parents 87b464c + 529985f commit 9e56e92
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 68 deletions.
23 changes: 6 additions & 17 deletions refm/api/src/_builtin/Array
Expand Up @@ -681,8 +681,7 @@ p copy #=> ["ing"]

各要素に対してブロックを評価した結果を全て含む配列を返します。

ブロックを省略した場合、上で説明した繰り返しを実行し、その結果として
得られる配列を返すような [[c:Enumerator]] オブジェクトを返します。
ブロックを省略した場合は [[c:Enumerator]] を返します。

#@samplecode 例
# すべて 3 倍にする
Expand Down Expand Up @@ -1662,8 +1661,7 @@ p a.rassoc(2) # => [25, 2]
その値が偽であった要素を集めた新しい配列を返します。
条件を反転させた select です。

ブロックを省略した場合は、各要素に対しブロックを評価し
偽になった値の配列を返すような [[c:Enumerator]] を返します。
ブロックを省略した場合は [[c:Enumerator]] を返します。

#@samplecode 例
# 偶数を除外する (奇数を集める)
Expand Down Expand Up @@ -1904,8 +1902,7 @@ p ary2.sort_by{|x| x.to_i } #=> ["7", "8", "9", "10", "11"]
--- sort_by! {|item| ... } -> self
sort_by の破壊的バージョンです。

ブロックを省略した場合は返り値によって配列を破壊的に
ソートする [[c:Enumerator]] を返します。
ブロックを省略した場合は [[c:Enumerator]] を返します。

#@samplecode 例
fruits = %w{apple pear fig}
Expand Down Expand Up @@ -1942,8 +1939,7 @@ a = [1, 2, 3, 4, 5, 0]
a.take_while {|i| i < 3 } # => [1, 2]
#@end

ブロックを省略した場合は、[[c:Enumerator]] オブジェクトを
返します。
ブロックを省略した場合は [[c:Enumerator]] を返します。

@see [[m:Enumerable#take_while]]

Expand Down Expand Up @@ -2269,13 +2265,7 @@ p a #=> [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]

配列の全要素を n 回(nilの場合は無限に)繰り返しブロックを呼びだします。

ブロックを省略した場合は、以上のような繰り返しを行う
#@until 1.9.1
[[c:Enumerable::Enumerator]]
#@else
[[c:Enumerator]]
#@end
を返します。
ブロックを省略した場合は [[c:Enumerator]] を返します。

@param n 繰り返したい回数を整数で指定します。
整数以外のオブジェクトを指定した場合は to_int メソッドによる暗
Expand Down Expand Up @@ -2543,8 +2533,7 @@ a # => ["a", "b", "c", "d", "e", "f"]
各要素に対してブロックを評価した値が真であった要素を全て含む配列を
返します。真になる要素がひとつもなかった場合は空の配列を返します。

ブロックを省略した場合は、各要素に対しブロックを評価し
真になった値の配列を返すような [[c:Enumerator]] を返します。
ブロックを省略した場合は [[c:Enumerator]] を返します。

#@samplecode 例
[1,2,3,4,5].select # => #<Enumerator: [1, 2, 3, 4, 5]:select>
Expand Down
39 changes: 12 additions & 27 deletions refm/api/src/_builtin/Enumerable
Expand Up @@ -97,8 +97,7 @@ e.to_a #=> [1, 2, 3, 4, 5]

各要素に対してブロックを評価した結果を全て含む配列を返します。

ブロックを省略した場合、上で説明した繰り返しを実行し、その結果として
得られる配列を返すような [[c:Enumerator]] オブジェクトを返します。
ブロックを省略した場合は [[c:Enumerator]] を返します。

#@samplecode 例
# すべて 3 倍にした配列を返す
Expand Down Expand Up @@ -156,8 +155,7 @@ end
真になる要素が見つからず、ifnone も指定されていないときは nil を返します。
真になる要素が見つからず、ifnone が指定されているときは ifnone を call した結果を返します。

ブロックを省略した場合は、各要素に対しブロックを真になるまで評価し、最初に
真になった値を返すような [[c:Enumerator]] を返します。
ブロックを省略した場合は [[c:Enumerator]] を返します。

@param ifnone call メソッドを持つオブジェクト (例えば [[c:Proc]]) を指定します。

Expand Down Expand Up @@ -186,8 +184,7 @@ p [1, 2, 3, 4, 5].find(ifnone) {|i| i % 7 == 0 }
各要素に対してブロックを評価した値が真であった要素を全て含む配列を
返します。真になる要素がひとつもなかった場合は空の配列を返します。

ブロックを省略した場合は、各要素に対しブロックを評価し
真になった値の配列を返すような [[c:Enumerator]] を返します。
ブロックを省略した場合は [[c:Enumerator]] を返します。

#@samplecode 例
(1..10).find_all # => #<Enumerator: 1..10:find_all>
Expand All @@ -207,8 +204,7 @@ p [1, 2, 3, 4, 5].find(ifnone) {|i| i % 7 == 0 }
各要素に対してブロックを評価した値のうち、真であった値の
配列を返します。

ブロックを省略した場合は、各要素に対してブロックを評価した値のうち、
真であった値の配列を返すような [[c:Enumerator]] を返します。
ブロックを省略した場合は [[c:Enumerator]] を返します。

#@samplecode 例
(1..10).filter_map { |i| i * 2 if i.even? } #=> [4, 8, 12, 16, 20]
Expand Down Expand Up @@ -560,10 +556,7 @@ a.min_by(2) {|x| x.length } # => ["dog", "horse"]
各要素に対してブロックを評価して、その値が真であった要素の配列と、
偽であった要素の配列の 2 つを配列に入れて返します。

ブロックを省略した場合は、各要素に対しブロックを評価し、
上のようにその値が真であった要素の配列と、
偽であった要素の配列のペアを返すような [[c:Enumerator]] を
返します。
ブロックを省略した場合は [[c:Enumerator]] を返します。

#@samplecode 例
[10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0].partition {|i| i % 3 == 0 }
Expand All @@ -577,8 +570,7 @@ a.min_by(2) {|x| x.length } # => ["dog", "horse"]
その値が偽であった要素を集めた新しい配列を返します。
条件を反転させた select です。

ブロックを省略した場合は、各要素に対しブロックを評価し
偽になった値の配列を返すような [[c:Enumerator]] を返します。
ブロックを省略した場合は [[c:Enumerator]] を返します。

#@samplecode 例
# 偶数を除外する (奇数を集める)
Expand Down Expand Up @@ -683,8 +675,7 @@ ary.sort_by {|v| [v, i += 1] }
※ 比較結果が同じ要素は元の順序通りに並ぶソートを
「安定なソート (stable sort)」と言います。

ブロックを省略した場合は、各要素をブロックで評価した値でソートした
配列を返すような [[c:Enumerator]] を返します。
ブロックを省略した場合は [[c:Enumerator]] を返します。


@see [[m:Enumerable#sort]]
Expand Down Expand Up @@ -948,8 +939,7 @@ e.first(2) #=> []
(1..6).group_by {|i| i%3} #=> {0=>[3, 6], 1=>[1, 4], 2=>[2, 5]}
#@end

ブロックを省略した場合は、最後に Hash を返す
[[c:Enumerator]] オブジェクトを返します。
ブロックを省略した場合は [[c:Enumerator]] を返します。

--- minmax -> [object, object]
--- minmax{|a, b| ... } -> [object, object]
Expand Down Expand Up @@ -995,8 +985,7 @@ a.minmax_by {|x| x.length } #=> ["dog", "albatross"]
[].minmax_by{} # => [nil, nil]
#@end

ブロックを省略した場合は、[[c:Enumerator]] オブジェクトを
返します。
ブロックを省略した場合は [[c:Enumerator]] を返します。

@see [[m:Enumerable#sort_by]]

Expand Down Expand Up @@ -1094,8 +1083,7 @@ e = [1, 2, 3, 4, 5, 0].each
e.take_while {|i| i < 3 } # => [1, 2]
#@end

ブロックを省略した場合は、[[c:Enumerator]] オブジェクトを
返します。
ブロックを省略した場合は [[c:Enumerator]] を返します。

@see [[m:Array#take_while]]

Expand All @@ -1122,8 +1110,7 @@ e.take_while {|i| i < 3 } # => [1, 2]

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

ブロックを省略した場合は、上の繰り返しをして、最初に与えたオブジェクトを
最後に返す [[c:Enumerator]] を返します。
ブロックを省略した場合は [[c:Enumerator]] を返します。

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

Expand All @@ -1142,9 +1129,7 @@ evens = (1..10).each_with_object([]) {|i, a| a << i*2 }

ブロックの返り値は基本的に配列を返すべきです。

ブロックを省略した場合は、ブロックを受けとり
上で説明した評価をし、その結果の配列を返す
[[c:Enumerator]] オブジェクトを返します。
ブロックを省略した場合は [[c:Enumerator]] を返します。

#@samplecode 例
[[1,2], [3,4]].flat_map{|i| i.map{|j| j*2}} # => [2,4,6,8]
Expand Down
5 changes: 1 addition & 4 deletions refm/api/src/_builtin/Struct
Expand Up @@ -273,10 +273,7 @@ joe.inspect # => "#<struct Customer name=\"Joe Smith\", address=\"123 Maple, Any
む配列を返します。真になる要素がひとつもなかった場合は空の配列を返しま
す。

#@since 1.9.1
ブロックを省略した場合は、各要素に対しブロックを評価し 真になった値の配
列を返すような [[c:Enumerator]] を返します。
#@end
ブロックを省略した場合は [[c:Enumerator]] を返します。

#@samplecode 例
Lots = Struct.new(:a, :b, :c, :d, :e, :f)
Expand Down
4 changes: 2 additions & 2 deletions refm/api/src/etc.rd
Expand Up @@ -470,7 +470,7 @@ alias Etc::Group
--- each -> Enumerator

/etc/group に含まれるエントリを一つずつブロックに渡して評価します。
ブロックを省略した場合は [[c:Enumerator]] のインスタンスを返します
ブロックを省略した場合は [[c:Enumerator]] を返します

@see [[m:Etc.#getpwent]]

Expand Down Expand Up @@ -548,7 +548,7 @@ alias Etc::Passwd
--- each -> Enumerator

/etc/passwd に含まれるエントリを一つずつブロックに渡して評価します。
ブロックを省略した場合は [[c:Enumerator]] のインスタンスを返します
ブロックを省略した場合は [[c:Enumerator]] を返します

@see [[m:Etc.#getpwent]]

Expand Down
5 changes: 1 addition & 4 deletions refm/api/src/find.rd
Expand Up @@ -52,10 +52,7 @@ category File
ディレクトリのシンボリックリンクは辿りません。
また file に渡される順序は不定です。

#@since 1.9.1
ブロックを省略した場合は、上記の処理を行うような [[c:Enumerator]] を返
します。
#@end
ブロックを省略した場合は [[c:Enumerator]] を返します。

@param dirs 探索するディレクトリを一つ以上指定します。

Expand Down
9 changes: 3 additions & 6 deletions refm/api/src/pathname.rd
Expand Up @@ -1092,10 +1092,7 @@ self 配下のすべてのファイルやディレクトリを

と同じです。

#@since 2.0.0
ブロックを省略した場合は、上記の処理を行うような [[c:Enumerator]] を返
します。
#@end
ブロックを省略した場合は [[c:Enumerator]] を返します。

#@since 2.2.0
@param ignore_error 探索中に発生した例外を無視するかどうかを指定します。
Expand Down Expand Up @@ -1135,7 +1132,7 @@ pathname.exist? # => false

self のパス名から親方向に辿っていったときの各パス名を新しい Pathname オ
ブジェクトとして生成し、ブロックへの引数として渡して実行します。
ブロックを省略した場合は、上記の処理を行うような [[c:Enumerator]] を返します。
ブロックを省略した場合は [[c:Enumerator]] を返します。

require 'pathname'

Expand All @@ -1160,7 +1157,7 @@ self のパス名から親方向に辿っていったときの各パス名を新
self のパス名の親から子供へと辿っていったときの各パス名を新しい
Pathname オブジェクトとして生成し、ブロックへの引数として渡して実行しま
す。
ブロックを省略した場合は、上記の処理を行うような [[c:Enumerator]] を返します。
ブロックを省略した場合は [[c:Enumerator]] を返します。

require 'pathname'

Expand Down
3 changes: 1 addition & 2 deletions refm/api/src/psych/Psych__Nodes
Expand Up @@ -98,8 +98,7 @@ YAML AST のノードを表す抽象クラスです。
self のノードをルートとする部分木の各ノードを引数として
ブロックを呼び出します。

ブロックを省略した場合は上のような繰り返しをする [[c:Enumerator]]
オブジェクトを返します。
ブロックを省略した場合は [[c:Enumerator]] を返します。

--- to_ruby -> object
--- transform -> object
Expand Down
6 changes: 2 additions & 4 deletions refm/api/src/rexml/parent.rd
Expand Up @@ -57,8 +57,7 @@ object を子ノード列から削除します。

各子ノードに対しブロックを呼び出します。

ブロックを省略した場合は、各子ノードに対し操作を
繰り返すような [[c:Enumerator]] オブジェクトを返します。
ブロックを省略した場合は [[c:Enumerator]] を返します。

--- delete_if {|object| ... } -> ()
#@since 1.9.1
Expand All @@ -67,8 +66,7 @@ object を子ノード列から削除します。

各子ノードに対しブロックを呼び出し、真を返したノードを削除します。

ブロックを省略した場合は、各子ノードに対し上の操作を
する [[c:Enumerator]] オブジェクトを返します。
ブロックを省略した場合は [[c:Enumerator]] を返します。


--- delete_at(index) -> REXML::Child | nil
Expand Down
3 changes: 1 addition & 2 deletions refm/api/src/socket/Addrinfo
Expand Up @@ -114,8 +114,7 @@ socktype でソケットタイプを指定します。

[[m:Addrinfo.getaddrinfo]] で得られる配列の各要素を繰り返します。

ブロックを省略した場合は繰り返しをする [[c:Enumerator]] オブジェクト
を返します。
ブロックを省略した場合は [[c:Enumerator]] を返します。

@param nodename ノード名文字列(ホスト名もしくは IP アドレス)
@param service サービス名(文字列もしくはポート番号の整数)
Expand Down

0 comments on commit 9e56e92

Please sign in to comment.