450件ヒット
[1-100件を表示]
(0.053秒)
別のキーワード
ライブラリ
- ビルトイン (294)
- csv (12)
- matrix (72)
-
net
/ http (36) -
rexml
/ document (36)
クラス
- Array (21)
-
CSV
:: Table (12) - Enumerator (24)
- Hash (158)
- Matrix (72)
-
REXML
:: Attributes (24) -
REXML
:: Element (12) - String (12)
- Struct (48)
- Thread (12)
モジュール
- Enumerable (19)
-
Net
:: HTTPHeader (36)
キーワード
- [] (12)
-
each
_ attribute (12) -
each
_ element _ with _ attribute (12) -
each
_ header (12) -
each
_ key (24) -
each
_ pair (48) -
each
_ value (36) - filter! (14)
-
find
_ index (36) - index (36)
-
keep
_ if (24) -
next
_ values (12) - pack (21)
-
peek
_ values (12) - select! (24)
-
to
_ h (19) - unpack (12)
検索結果
先頭5件
-
Hash
# each {|key , value| . . . } -> self (18273.0) -
ハッシュのキーと値を引数としてブロックを評価します。
...
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_val... -
CSV
:: Table # each {|column _ name , values| . . . } -> self (18239.0) -
デフォルトのミックスモードかロウモードでは、行単位で繰り返します。カラ ムモードでは、ブロックに列名と対応する値の配列を与え、列単位で繰り返し ます。
...ウモード][ruby]{
require "csv"
row1 = CSV::Row.new(["header1", "header2"], ["row1_1", "row1_2"])
row2 = CSV::Row.new(["header1", "header2"], ["row2_1", "row2_2"])
row3 = CSV::Row.new(["header1", "header2"], ["row3_1", "row3_2"])
table = CSV::Table.new([row1, row2, row3])
table.each { |row| p ro......ド][ruby]{
require "csv"
row1 = CSV::Row.new(["header1", "header2"], ["row1_1", "row1_2"])
row2 = CSV::Row.new(["header1", "header2"], ["row2_1", "row2_2"])
row3 = CSV::Row.new(["header1", "header2"], ["row3_1", "row3_2"])
table = CSV::Table.new([row1, row2, row3])
table.by_col!
table.each { |colu......mn_name, values| print column_name, values, "\n" }
# => header1["row1_1", "row2_1", "row3_1"]
# => header2["row1_2", "row2_2", "row3_2"]
//}... -
REXML
:: Attributes # each {|name , value| . . . } -> () (18233.0) -
各属性の名前と値に対しブロックを呼び出します。
...t[][ruby]{
require 'rexml/document'
doc = REXML::Document.new(<<EOS)
<root xmlns:foo="http://example.org/foo"
xmlns:bar="http://example.org/bar">
<a foo:att='1' bar:att='2' att='<'/>
</root>
EOS
a = doc.get_elements("/root/a").first
a.attributes.each do |name, value|
p [name, value]
e... -
Struct
# each {|value| . . . } -> self (18222.0) -
構造体の各メンバに対して繰り返します。
...ct.new は Struct の下位クラスを作成する点に
注意してください。
//emlist[例][ruby]{
Customer = Struct.new(:name, :address, :zip)
joe = Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345)
joe.each {|x| puts(x) }
# => Joe Smith
# 123 Maple, Anytown NC
# 12345
//}... -
Hash
# each -> Enumerator (18173.0) -
ハッシュのキーと値を引数としてブロックを評価します。
...
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_val... -
Net
:: HTTPHeader # each {|name , val| . . . . } -> () (18145.0) -
保持しているヘッダ名とその値をそれぞれ ブロックに渡して呼びだします。
...mlist[例][ruby]{
require 'net/http'
uri = URI.parse('http://www.example.com/index.html')
req = Net::HTTP::Get.new(uri.request_uri)
req.each_header { |key,value| puts "#{key} = #{value}" }
# => accept-encoding = gzip;q=1.0,deflate;q=0.6,identity;q=0.3
# => accept = */*
# => user-agent = Ruby
//}... -
Struct
# each -> Enumerator (18122.0) -
構造体の各メンバに対して繰り返します。
...ct.new は Struct の下位クラスを作成する点に
注意してください。
//emlist[例][ruby]{
Customer = Struct.new(:name, :address, :zip)
joe = Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345)
joe.each {|x| puts(x) }
# => Joe Smith
# 123 Maple, Anytown NC
# 12345
//}... -
Hash
# each _ value {|value| . . . } -> self (12366.0) -
ハッシュの値を引数としてブロックを評価します。
...た順です。
ブロック付きの場合selfを、
無しで呼ばれた場合 Enumerator を返します。
//emlist[例][ruby]{
{:a=>1, :b=>2}.each_value {|v| p v}
#=> 1
# 2
p({:a=>1, :b=>2}.each_value) # => #<Enumerator: {:a=>1, :b=>2}:each_value>
//}
@see Hash#each_pair,Hash#each_key... -
Net
:: HTTPHeader # each _ value {|value| . . . . } -> () (12352.0) -
保持しているヘッダの値をブロックに渡し、呼びだします。
...れる文字列は ", " で連結したものです。
//emlist[例][ruby]{
require 'net/http'
uri = URI.parse('http://www.example.com/index.html')
req = Net::HTTP::Get.new(uri.request_uri)
req.each_value { |value| puts value }
# => gzip;q=1.0,deflate;q=0.6,identity;q=0.3
# => */*
# => Ruby
//}...