別のキーワード
種類
- インスタンスメソッド (2442)
- 文書 (131)
- 特異メソッド (116)
- ライブラリ (17)
ライブラリ
クラス
-
ARGF
. class (238) - Array (176)
-
CSV
:: Row (22) -
CSV
:: Table (33) - DBM (66)
- Dir (34)
- Enumerator (55)
-
Enumerator
:: ArithmeticSequence (12) -
Enumerator
:: Lazy (11) - GDBM (66)
- GetoptLong (11)
- Hash (155)
- IO (282)
- Matrix (68)
- Module (33)
- Object (44)
-
OpenSSL
:: ASN1 :: Constructive (11) -
OpenSSL
:: Config (11) - OpenStruct (22)
- Pathname (68)
-
Prime
:: PseudoPrimeGenerator (66) -
Psych
:: Nodes :: Node (22) - Range (33)
- SDBM (66)
- Set (44)
- Shell (6)
- String (215)
- StringIO (166)
- Struct (44)
- Thread (33)
-
Thread
:: SizedQueue (9) - Vector (44)
- WIN32OLE (11)
-
WIN32OLE
_ TYPE (11) -
Zlib
:: GzipReader (44)
モジュール
- Enumerable (227)
-
REXML
:: Node (11)
オブジェクト
- ENV (88)
キーワード
-
1
. 6 . 8から1 . 8 . 0への変更点(まとめ) (11) -
NEWS for Ruby 2
. 0 . 0 (11) -
NEWS for Ruby 2
. 1 . 0 (11) -
NEWS for Ruby 2
. 5 . 0 (7) -
NEWS for Ruby 2
. 6 . 0 (6) -
NEWS for Ruby 2
. 7 . 0 (5) -
NEWS for Ruby 3
. 1 . 0 (3) - Rubyで使われる記号の意味(正規表現の複雑な記号は除く) (11)
-
alias
_ command (6) -
append
_ features (11) - bytes (64)
- chars (64)
-
chunk
_ while (11) - close (9)
- codepoints (64)
- collect! (34)
-
default
_ event _ sources (11) -
delete
_ if (22) - each2 (22)
-
each
_ byte (88) -
each
_ char (88) -
each
_ child (34) -
each
_ codepoint (88) -
each
_ cons (6) -
each
_ entry (35) -
each
_ filename (11) -
each
_ grapheme _ cluster (14) -
each
_ index (22) -
each
_ key (77) -
each
_ line (198) -
each
_ pair (121) -
each
_ recursive (11) -
each
_ slice (6) -
each
_ value (77) -
each
_ with _ index (66) -
enum
_ for (22) -
extend
_ object (11) - filter! (12)
-
grapheme
_ clusters (14) - inject (33)
-
instance
_ method (11) - join (22)
-
keep
_ if (22) - lines (120)
- map! (34)
- merge (11)
- new (22)
- pp (11)
- profile (6)
- push (22)
- reduce (33)
- rehash (11)
- reject! (22)
- replace (44)
-
reverse
_ each (44) - rewind (11)
-
ruby 1
. 6 feature (11) -
ruby 1
. 8 . 2 feature (11) -
ruby 1
. 8 . 3 feature (11) -
ruby 1
. 8 . 4 feature (11) - select! (22)
-
slice
_ when (11) - subtract (11)
- sum (22)
-
to
_ enum (22) -
to
_ h (17) - update (33)
- upto (11)
- value (11)
-
with
_ index (22) - zip (44)
- メソッド呼び出し(super・ブロック付き・yield) (11)
- 制御構造 (11)
検索結果
先頭5件
-
Enumerator
# each -> self (18265.0) -
生成時のパラメータに従ってブロックを繰り返します。 *args を渡した場合は、生成時のパラメータ内引数末尾へ *args を追加した状態で繰り返します。 ブロック付きで呼び出された場合は、 生成時に指定したイテレータの戻り値をそのまま返します。
...末尾へ追加する引数
//emlist[例1][ruby]{
str = "Yet Another Ruby Hacker"
enum = Enumerator.new {|y| str.scan(/\w+/) {|w| y << w }}
enum.each {|word| p word } # => "Yet"
# "Another"
# "Ruby"......scan).each(/\w+/).to_a # => ["Hello", "world"]
obj = Object.new
def obj.each_arg(a, b=:b, *rest)
yield a
yield b
yield rest
:method_returned
end
enum = obj.to_enum :each_arg, :a, :x
enum.each.to_a # => [:a, :x, []]
enum.each.equal?(enum) # => true
enum.each { |e......lm| elm } # => :method_returned
enum.each(:y, :z).to_a # => [:a, :x, [:y, :z]]
enum.each(:y, :z).equal?(enum) # => false
enum.each(:y, :z) { |elm| elm } # => :method_returned
//}... -
Hash
# each {|key , value| . . . } -> self (18260.0) -
ハッシュのキーと値を引数としてブロックを評価します。
...の場合 self を、
無しで呼ばれた場合 Enumerator を返します。
each_pair は each のエイリアスです。
//emlist[例][ruby]{
{:a=>1, :b=>2}.each {|a| p a}
#=> [:a, 1]
# [:b, 2]
{:a=>1, :b=>2}.each {|k, v| p [k, v]}
#=> [:a, 1]
# [:b, 2]
p({:a=>1, :b=>2}.each_pair) # =......> #<Enumerator: {:a=>1, :b=>2}:each_pair>
//}
@see Hash#each_key,Hash#each_value... -
Zlib
:: GzipReader # each(rs = $ / ) {|line| . . . } -> self (18256.0) -
IO クラスの同名メソッドIO#each, IO#each_lineと同じです。
...IO クラスの同名メソッドIO#each, IO#each_lineと同じです。
但し、gzip ファイル中に
エラーがあった場合 Zlib::Error 例外や
Zlib::GzipFile::Error 例外が発生します。
gzip ファイルのフッターの処理に注意して下さい。
gzip ファイルの......照
require 'zlib'
=begin
# hoge.gz がない場合は下記で作成できる。
Zlib::GzipWriter.open('hoge.gz') { |gz|
gz.puts 'hoge'
gz.puts 'fuga'
}
=end
Zlib::GzipReader.open('hoge.gz') { |gz|
gz.each { |line|
puts line
}
}
@see IO#each, IO#each_line... -
IO
# each(limit , chomp: false) {|line| . . . } -> self (18236.0) -
IO の現在位置から 1 行ずつ文字列として読み込み、それを引数として 与えられたブロックを実行します。
...: 引数なし][ruby]{
IO.write("testfile", "This is line one,\nThis is line two,\nThis is line three,\nAnd so on...")
f = File.new("testfile")
f.each { |line| p "#{f.lineno}: #{line}" }
# => "1: This is line one,\n"
# "2: This is line two,\n"
# "3: This is line three,\n"
# "4: And so on..."
//}
//e......ト数に 10 を指定][ruby]{
IO.write("testfile", "This is line one,This is line two,This is line three,And so on...")
f = File.new("testfile")
f.each(",", 10) { |line| p "#{f.lineno}: #{line}" }
# => "0: This is li"
# "1: ne one,"
# "1: This is li"
# "2: ne two,"
# "2: This is li"
# "3: ne three,......t[例: chomp = true][ruby]{
IO.write("testfile", "This is line one\nThis is line two\nThis is line three\nAnd so on...")
f = File.new("testfile")
f.each(chomp: true) { |line| p "#{f.lineno}: #{line}" }
# => "1: This is line one"
# "2: This is line two"
# "3: This is line three"
# "4: And so on..."
/... -
IO
# each(rs = $ / , chomp: false) {|line| . . . } -> self (18236.0) -
IO の現在位置から 1 行ずつ文字列として読み込み、それを引数として 与えられたブロックを実行します。
...: 引数なし][ruby]{
IO.write("testfile", "This is line one,\nThis is line two,\nThis is line three,\nAnd so on...")
f = File.new("testfile")
f.each { |line| p "#{f.lineno}: #{line}" }
# => "1: This is line one,\n"
# "2: This is line two,\n"
# "3: This is line three,\n"
# "4: And so on..."
//}
//e......ト数に 10 を指定][ruby]{
IO.write("testfile", "This is line one,This is line two,This is line three,And so on...")
f = File.new("testfile")
f.each(",", 10) { |line| p "#{f.lineno}: #{line}" }
# => "0: This is li"
# "1: ne one,"
# "1: This is li"
# "2: ne two,"
# "2: This is li"
# "3: ne three,......t[例: chomp = true][ruby]{
IO.write("testfile", "This is line one\nThis is line two\nThis is line three\nAnd so on...")
f = File.new("testfile")
f.each(chomp: true) { |line| p "#{f.lineno}: #{line}" }
# => "1: This is line one"
# "2: This is line two"
# "3: This is line three"
# "4: And so on..."
/... -
IO
# each(rs , limit , chomp: false) {|line| . . . } -> self (18236.0) -
IO の現在位置から 1 行ずつ文字列として読み込み、それを引数として 与えられたブロックを実行します。
...: 引数なし][ruby]{
IO.write("testfile", "This is line one,\nThis is line two,\nThis is line three,\nAnd so on...")
f = File.new("testfile")
f.each { |line| p "#{f.lineno}: #{line}" }
# => "1: This is line one,\n"
# "2: This is line two,\n"
# "3: This is line three,\n"
# "4: And so on..."
//}
//e......ト数に 10 を指定][ruby]{
IO.write("testfile", "This is line one,This is line two,This is line three,And so on...")
f = File.new("testfile")
f.each(",", 10) { |line| p "#{f.lineno}: #{line}" }
# => "0: This is li"
# "1: ne one,"
# "1: This is li"
# "2: ne two,"
# "2: This is li"
# "3: ne three,......t[例: chomp = true][ruby]{
IO.write("testfile", "This is line one\nThis is line two\nThis is line three\nAnd so on...")
f = File.new("testfile")
f.each(chomp: true) { |line| p "#{f.lineno}: #{line}" }
# => "1: This is line one"
# "2: This is line two"
# "3: This is line three"
# "4: And so on..."
/... -
ARGF
. class # each(rs = $ / ) { |line| . . . } -> self (18230.0) -
ARGFの現在位置から 1 行ずつ文字列として読み込み、それを引数として与えら れたブロックを実行します。
...フモード)。
@param limit 各行の最大の読み込みバイト数
例: ARGFの各ファイル名(最初に1回のみ)、行番号、内容を表示
ARGF.each_line do |line|
puts ARGF.filename if ARGF.lineno == 1
puts "#{ARGF.lineno}: #{line}"
end
@see IO#each, IO#each_line... -
ARGF
. class # each(rs = $ / , limit) { |line| . . . } -> self (18230.0) -
ARGFの現在位置から 1 行ずつ文字列として読み込み、それを引数として与えら れたブロックを実行します。
...フモード)。
@param limit 各行の最大の読み込みバイト数
例: ARGFの各ファイル名(最初に1回のみ)、行番号、内容を表示
ARGF.each_line do |line|
puts ARGF.filename if ARGF.lineno == 1
puts "#{ARGF.lineno}: #{line}"
end
@see IO#each, IO#each_line... -
IO
# each(limit) {|line| . . . } -> self (18230.0) -
IO の現在位置から 1 行ずつ文字列として読み込み、それを引数として 与えられたブロックを実行します。
...: 引数なし][ruby]{
IO.write("testfile", "This is line one,\nThis is line two,\nThis is line three,\nAnd so on...")
f = File.new("testfile")
f.each { |line| p "#{f.lineno}: #{line}" }
# => "1: This is line one,\n"
# "2: This is line two,\n"
# "3: This is line three,\n"
# "4: And so on..."
//}
//e......ト数に 10 を指定][ruby]{
IO.write("testfile", "This is line one,This is line two,This is line three,And so on...")
f = File.new("testfile")
f.each(",", 10) { |line| p "#{f.lineno}: #{line}" }
# => "0: This is li"
# "1: ne one,"
# "1: This is li"
# "2: ne two,"
# "2: This is li"
# "3: ne three,... -
IO
# each(rs = $ / ) {|line| . . . } -> self (18230.0) -
IO の現在位置から 1 行ずつ文字列として読み込み、それを引数として 与えられたブロックを実行します。
...: 引数なし][ruby]{
IO.write("testfile", "This is line one,\nThis is line two,\nThis is line three,\nAnd so on...")
f = File.new("testfile")
f.each { |line| p "#{f.lineno}: #{line}" }
# => "1: This is line one,\n"
# "2: This is line two,\n"
# "3: This is line three,\n"
# "4: And so on..."
//}
//e......ト数に 10 を指定][ruby]{
IO.write("testfile", "This is line one,This is line two,This is line three,And so on...")
f = File.new("testfile")
f.each(",", 10) { |line| p "#{f.lineno}: #{line}" }
# => "0: This is li"
# "1: ne one,"
# "1: This is li"
# "2: ne two,"
# "2: This is li"
# "3: ne three,... -
IO
# each(rs , limit) {|line| . . . } -> self (18230.0) -
IO の現在位置から 1 行ずつ文字列として読み込み、それを引数として 与えられたブロックを実行します。
...: 引数なし][ruby]{
IO.write("testfile", "This is line one,\nThis is line two,\nThis is line three,\nAnd so on...")
f = File.new("testfile")
f.each { |line| p "#{f.lineno}: #{line}" }
# => "1: This is line one,\n"
# "2: This is line two,\n"
# "3: This is line three,\n"
# "4: And so on..."
//}
//e......ト数に 10 を指定][ruby]{
IO.write("testfile", "This is line one,This is line two,This is line three,And so on...")
f = File.new("testfile")
f.each(",", 10) { |line| p "#{f.lineno}: #{line}" }
# => "0: This is li"
# "1: ne one,"
# "1: This is li"
# "2: ne two,"
# "2: This is li"
# "3: ne three,... -
Array
# each {|item| . . . . } -> self (18227.0) -
各要素に対してブロックを評価します。
...してブロックを評価します。
ブロックが与えられなかった場合は、自身と each から生成した
Enumerator オブジェクトを返します。
//emlist[例][ruby]{
[1, 2, 3].each do |i|
puts i
end
#=> 1
# 2
# 3
//}
@see Array#each_index, Array#reverse_each... -
Matrix
# each(which = :all) {|e| . . . } -> self (18221.0) -
行列の各要素を引数としてブロックを呼び出します。
...uby]{
require 'matrix'
Matrix[ [1,2], [3,4] ].each { |e| puts e }
# => prints the numbers 1 to 4
Matrix[ [1,2], [3,4] ].each(:strict_lower).to_a # => [3]
//}
@param which どの要素に対してブロックを呼び出すのかを Symbol で指定します
@see Matrix#each_with_index, Matrix#map...