206件ヒット
[1-100件を表示]
(0.137秒)
ライブラリ
- ビルトイン (129)
-
rexml
/ document (66) -
webrick
/ httputils (11)
クラス
- Array (19)
-
Enumerator
:: Lazy (44) -
Enumerator
:: Yielder (11) -
REXML
:: Attributes (22) -
REXML
:: Element (22) -
REXML
:: Elements (22) - String (11)
-
WEBrick
:: HTTPUtils :: FormData (11)
モジュール
- Enumerable (44)
キーワード
- << (11)
-
chunk
_ while (11) -
each
_ attribute (11) -
each
_ data (11) -
each
_ element _ with _ attribute (11) -
each
_ element _ with _ text (11) -
enum
_ for (22) - pack (19)
-
slice
_ when (11) -
take
_ while (22) -
to
_ a (11) -
to
_ enum (22) - unpack (11)
検索結果
先頭5件
- REXML
:: Elements # each(xpath = nil) {|element| . . . } -> [REXML :: Elements] - REXML
:: Attributes # each {|name , value| . . . } -> () - REXML
:: Element # each _ element _ with _ attribute(key , value = nil , max = 0 , name = nil) {|element| . . . } -> () - REXML
:: Element # each _ element _ with _ text(text = nil , max = 0 , name = nil) {|element| . . . } -> () - Enumerable
# take _ while {|element| . . . } -> Array
-
REXML
:: Elements # each(xpath = nil) {|element| . . . } -> [REXML :: Elements] (21274.0) -
全ての子要素に対しブロックを呼び出します。
...ML::XPath.each などとは異なり、要素以外の
テキストノードなどはすべて無視されることに注意してください。
@param xpath XPath文字列
//emlist[][ruby]{
require 'rexml/document'
require 'rexml/xpath'
doc = REXML::Document.new '<a><b/><c/><d/>sean<b/><c/><d/><......>'
# <b/>,<c/>,<d/>,<b/>,<c/>, <d/> がブロックに渡される
doc.root.elements.each {|e|p e}
# <b/>, <b/> がブロックに渡される
doc.root.elements.each('b') {|e|p e} #-> Yields b, b elements
# <b/>,<c/>,<d/>,<b/>,<c/>,<d/> がブロックに渡される
doc.root.elements.each('child::......node()') {|e|p e}
# <b/>,<c/>,<d/>,"sean",<b/>,<c/>,<d/> がブロックに渡される
REXML::XPath.each(doc.root, 'child::node()'){|node| p node }
//}... -
REXML
:: Attributes # each {|name , value| . . . } -> () (21220.0) -
各属性の名前と値に対しブロックを呼び出します。
...d_name(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("/r......oot/a").first
a.attributes.each do |name, value|
p [name, value]
end
# => ["foo:att", "1"]
# => ["bar:att", "2"]
# => ["att", "<"]
//}... -
REXML
:: Element # each _ element _ with _ attribute(key , value = nil , max = 0 , name = nil) {|element| . . . } -> () (12368.0) -
特定の属性を持つすべての子要素を引数としてブロックを呼び出します。
...を呼び出します。
key で指定した属性名の属性を持つ要素のみを対象とします。
value を指定すると、keyで指定した属性名を持つ属性の値がvalueである
もののみを対象とします。
maxを指定すると、対象となる子要素の先頭 max......(文字列)
@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_element_with_attribute(......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', '1', 0, 'd'){|e| p e }
# >> <d id='1'/>
//}... -
REXML
:: Element # each _ element _ with _ text(text = nil , max = 0 , name = nil) {|element| . . . } -> () (12368.0) -
テキストを子ノードとして 持つすべての子要素を引数としてブロックを呼び出します。
...//emlist[][ruby]{
require 'rexml/document'
doc = REXML::Document.new '<a><b>b</b><c>b</c><d>d</d><e/></a>'
doc.root.each_element_with_text {|e|p e}
# >> <b> ... </>
# >> <c> ... </>
# >> <d> ... </>
doc.root.each_element_with_text('b'){|e|p e}
# >> <b> ... </>
# >> <c> ... </>
doc.root.each_element......_with_text('b', 1){|e|p e}
# >> <b> ... </>
doc.root.each_element_with_text(nil, 0, 'd'){|e|p e}
# >> <d> ... </>
//}... -
Enumerable
# take _ while {|element| . . . } -> Array (9213.0) -
Enumerable オブジェクトの要素を順に偽になるまでブロックで評価します。 最初に偽になった要素の手前の要素までを配列として返します。
...Enumerable オブジェクトの要素を順に偽になるまでブロックで評価します。
最初に偽になった要素の手前の要素までを配列として返します。
//emlist[例][ruby]{
e = [1, 2, 3, 4, 5, 0].each
e.take_while {|i| i < 3 } # => [1, 2]
//}
ブロックを......省略した場合は Enumerator を返します。
@see Array#take_while... -
REXML
:: Attributes # each _ attribute {|attribute| . . . } -> () (9120.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("/r......oot/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", "<"]
//}... -
Enumerable
# chunk _ while {|elt _ before , elt _ after| . . . } -> Enumerator (9119.0) -
要素を前から順にブロックで評価し、その結果によって要素をチャンクに分け た(グループ化した)要素を持つEnumerator を返します。
...elt_before、elt_after に渡し、ブロックの
評価値が偽になる所でチャンクを区切ります。
ブロックは self の長さ - 1 回呼び出されます。
@return チャンクごとの配列をブロックパラメータに渡す Enumerator
を返します。eachメ......ドは以下のように呼び出します。
//emlist{
enum.chunk_while { |elt_before, elt_after| bool }.each { |ary| ... }
//}
to_a や map などのその他の Enumerable モジュールのメソッ
ドも有用です。
//emlist[例][ruby]{
# 1ずつ増加する部分配列......ごとに分ける。
a = [1,2,4,9,10,11,12,15,16,19,20,21]
b = a.chunk_while {|i, j| i+1 == j }
p b.to_a # => [[1, 2], [4], [9, 10, 11, 12], [15, 16], [19, 20, 21]]
c = b.map {|a| a.length < 3 ? a : "#{a.first}-#{a.last}" }
p c # => [[1, 2], [4], "9-12", [15, 16], "19-21"]
d = c.join(",")
p d # =>... -
Enumerator
:: Yielder # <<(object) -> () (9119.0) -
Enumerator.new で使うメソッドです。
...ブジェクトの each メソッドを呼ぶと
Enumerator::Yielder オブジェクトが渡されたブロックが実行され、
ブロック内の << が呼ばれるたびに each に渡されたブロックが
<< に渡された値とともに繰り返されます。
//emlist[例][ruby]{
enum......= Enumerator.new do |y|
y << 1
y << 2
y << 3
end
enum.each do |v|
p v
end
# => 1
# 2
# 3
//}... -
WEBrick
:: HTTPUtils :: FormData # each _ data {|s| . . . } (9114.0) -
自身が表す各フォームデータを引数として、与えられたブロックを実行します。
...ムデータを引数として、与えられたブロックを実行します。
例:
require "webrick/cgi"
class MyCGI < WEBrick::CGI
def do_GET(req, res)
req.query['q'].each_data{|s|
p s
}
#=> "val1"
"val2"
"val3"
end
end
MyCGI.new.start()... -
Enumerable
# take _ while -> Enumerator (9113.0) -
Enumerable オブジェクトの要素を順に偽になるまでブロックで評価します。 最初に偽になった要素の手前の要素までを配列として返します。
...Enumerable オブジェクトの要素を順に偽になるまでブロックで評価します。
最初に偽になった要素の手前の要素までを配列として返します。
//emlist[例][ruby]{
e = [1, 2, 3, 4, 5, 0].each
e.take_while {|i| i < 3 } # => [1, 2]
//}
ブロックを......省略した場合は Enumerator を返します。
@see Array#take_while...