392件ヒット
[1-100件を表示]
(0.146秒)
別のキーワード
ライブラリ
- ビルトイン (248)
- matrix (72)
-
net
/ http (36) -
rexml
/ document (36)
クラス
- Array (21)
- Enumerator (24)
- Hash (112)
- 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 (12) -
each
_ pair (48) -
each
_ value (24) - filter! (14)
-
find
_ index (36) - index (36)
-
keep
_ if (19) -
next
_ values (12) - pack (21)
-
peek
_ values (12) - select! (19)
-
to
_ h (19) - unpack (12)
検索結果
先頭5件
-
REXML
:: Attributes # each {|name , value| . . . } -> () (21233.0) -
各属性の名前と値に対しブロックを呼び出します。
...ame(REXML::Namespace#exapnded_name)が
渡されます。
//emlist[][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]
end
# => ["foo:att", "1"]
# => ["bar:att", "2"]
# => ["att", "<"]
//}... -
Struct
# each -> Enumerator (21222.0) -
構造体の各メンバに対して繰り返します。
...の記述は Struct の下位クラスのインスタンスに対して呼び
出す事を想定しています。Struct.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
//}... -
Struct
# each {|value| . . . } -> self (21222.0) -
構造体の各メンバに対して繰り返します。
...の記述は Struct の下位クラスのインスタンスに対して呼び
出す事を想定しています。Struct.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
//}... -
Net
:: HTTPHeader # each {|name , val| . . . . } -> () (21145.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
//}... -
Hash
# each -> Enumerator (18273.0) -
ハッシュのキーと値を引数としてブロックを評価します。
...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>
//}
@s......ee Hash#each_key,Hash#each_value... -
Net
:: HTTPHeader # each _ value {|value| . . . . } -> () (15352.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
//}... -
Hash
# each _ value -> Enumerator (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... -
REXML
:: Element # each _ element _ with _ attribute(key , value = nil , max = 0 , name = nil) {|element| . . . } -> () (12357.0) -
特定の属性を持つすべての子要素を引数としてブロックを呼び出します。
...を呼び出します。
key で指定した属性名の属性を持つ要素のみを対象とします。
value を指定すると、keyで指定した属性名を持つ属性の値がvalueである
もののみを対象とします。
maxを指定すると、対象となる子要素の先頭 max......@param key 属性名(文字列)
@param value 属性値(文字列)
@param max ブロック呼出の対象とする子要素の最大個数
@param name xpath文字列
//emlist[][ruby]{
require 'rexml/document'
doc = REXML::Document.new("<a><b id='1'/><c id='2'/><d id='1'/><e/></a>")
doc.root.each_el......ment_with_attribute('id'){|e| p e }
# >> <b id='1'/>
# >> <c id='2'/>
# >> <d id='1'/>
doc.root.each_element_with_attribute('id', '1'){|e| p e }
# >> <b id='1'/>
# >> <d id='1'/>
doc.root.each_element_with_attribute('id', '1', 1){|e| p e }
# >> <b id='1'/>
doc.root.each_element_with_attribute('id',... -
REXML
:: Attributes # each _ attribute {|attribute| . . . } -> () (12326.0) -
各属性に対しブロックを呼び出します。
... REXML::Attribute オブジェクトで渡されます。
//emlist[][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_attribute do |attr|
p [attr.namespace, attr.name, attr.value]
end
# => ["http://example.org/foo", "att", "1"]
# => ["http://example.org/bar", "att", "2"]
# => ["", "att", "<"]
//}...