種類
- インスタンスメソッド (491)
- 文書 (51)
ライブラリ
- ビルトイン (331)
- matrix (22)
-
net
/ smtp (33) - ostruct (22)
-
rexml
/ document (11) - shell (24)
-
shell
/ command-processor (24) -
shell
/ filter (24)
クラス
-
ARGF
. class (22) - Enumerator (50)
- Matrix (22)
-
Net
:: SMTP (33) - OpenStruct (22)
-
REXML
:: Elements (11) - Shell (24)
-
Shell
:: CommandProcessor (24) -
Shell
:: Filter (24) - String (160)
モジュール
- Enumerable (99)
キーワード
- + (6)
-
1
. 6 . 8から1 . 8 . 0への変更点(まとめ) (11) -
NEWS for Ruby 2
. 0 . 0 (11) -
NEWS for Ruby 3
. 0 . 0 (4) -
NEWS for Ruby 3
. 1 . 0 (3) - bytes (22)
- cat (18)
- chars (22)
- chunk (11)
-
chunk
_ while (11) - codepoints (22)
-
each
_ byte (22) -
each
_ codepoint (22) -
each
_ grapheme _ cluster (14) -
each
_ line (22) -
each
_ pair (22) - echo (18)
- entries (11)
- glob (18)
-
grapheme
_ clusters (14) - lines (22)
-
ruby 1
. 6 feature (11) -
send
_ mail (11) - sendmail (11)
-
slice
_ after (22) -
slice
_ before (22) -
slice
_ when (11) - tee (18)
- メソッド呼び出し(super・ブロック付き・yield) (11)
検索結果
先頭5件
-
Enumerator
# each -> self (18288.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"......um(:scan, /\w+/).to_a # => ["Hello", "world"]
"Hello, world!".to_enum(: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 { |elm| 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
//}... -
Enumerator
# each { . . . } -> object (18288.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"......um(:scan, /\w+/).to_a # => ["Hello", "world"]
"Hello, world!".to_enum(: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 { |elm| 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
//}... -
Enumerator
# each(*args) -> Enumerator (18288.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"......um(:scan, /\w+/).to_a # => ["Hello", "world"]
"Hello, world!".to_enum(: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 { |elm| 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
//}... -
Enumerator
# each(*args) { . . . } -> object (18288.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"......um(:scan, /\w+/).to_a # => ["Hello", "world"]
"Hello, world!".to_enum(: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 { |elm| 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
//}... -
Matrix
# each(which = :all) -> Enumerator (18238.0) -
行列の各要素を引数としてブロックを呼び出します。
...以下の Symbol を指定することで
引数として使われる要素を限定することができます。
* :all - すべての要素(デフォルト)
* :diagonal - 対角要素
* :off_diagonal 対角要素以外
* :lower 対角成分とそれより下側の部分
* :upper対角......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... -
Matrix
# each(which = :all) {|e| . . . } -> self (18238.0) -
行列の各要素を引数としてブロックを呼び出します。
...以下の Symbol を指定することで
引数として使われる要素を限定することができます。
* :all - すべての要素(デフォルト)
* :diagonal - 対角要素
* :off_diagonal 対角要素以外
* :lower 対角成分とそれより下側の部分
* :upper対角......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... -
REXML
:: Elements # to _ a(xpath = nil) -> [REXML :: Element] (18219.0) -
すべての子要素の配列を返します。
...Elements#each と同様、REXML::XPath.match などと
異なり、要素以外の子ノードは無視されます。
@param xpath XPath文字列
//emlist[][ruby]{
require 'rexml/document'
require 'rexml/xpath'
doc = REXML::Document.new '<a>sean<b/>elliott<c/></a>'
doc.root.elements.to_a # => [......<b/>, <c/>]
doc.root.elements.to_a("child::node()") # => [<b/>, <c/>]
REXML::XPath.match(doc.root, "child::node()") # => ["sean", <b/>, "elliott", <c/>]
//}... -
Enumerable
# to _ a(*args) -> [object] (15219.0) -
全ての要素を含む配列を返します。
...全ての要素を含む配列を返します。
@param args each の呼び出し時に引数として渡されます。
//emlist[例][ruby]{
(1..7).to_a #=> [1, 2, 3, 4, 5, 6, 7]
{ 'a'=>1, 'b'=>2, 'c'=>3 }.to_a #=> [["a", 1], ["b", 2], ["c", 3]]
require 'prime'
Prime.ent... -
String
# each _ codepoint -> Enumerator (6256.0) -
文字列の各コードポイントに対して繰り返します。
...トに対して繰り返します。
UTF-8/UTF-16(BE|LE)/UTF-32(BE|LE) 以外のエンコーディングに対しては
各文字のバイナリ表現由来の値になります。
//emlist[例][ruby]{
#coding:UTF-8
"hello わーるど".each_codepoint.to_a
# => [104, 101, 108, 108, 111, 32, 12431,......12540, 12427, 12393]
"hello わーるど".encode('euc-jp').each_codepoint.to_a
# => [104, 101, 108, 108, 111, 32, 42223, 41404, 42219, 42185]
//}
@see String#codepoints... -
String
# each _ codepoint {|codepoint| block } -> self (6256.0) -
文字列の各コードポイントに対して繰り返します。
...トに対して繰り返します。
UTF-8/UTF-16(BE|LE)/UTF-32(BE|LE) 以外のエンコーディングに対しては
各文字のバイナリ表現由来の値になります。
//emlist[例][ruby]{
#coding:UTF-8
"hello わーるど".each_codepoint.to_a
# => [104, 101, 108, 108, 111, 32, 12431,......12540, 12427, 12393]
"hello わーるど".encode('euc-jp').each_codepoint.to_a
# => [104, 101, 108, 108, 111, 32, 42223, 41404, 42219, 42185]
//}
@see String#codepoints...