種類
- インスタンスメソッド (108)
- 文書 (40)
- 特異メソッド (34)
- ライブラリ (11)
ライブラリ
- csv (11)
- pathname (68)
-
rexml
/ document (33) - shell (18)
-
shell
/ command-processor (6) -
shell
/ filter (6)
クラス
- CSV (11)
- Pathname (68)
-
REXML
:: Elements (22) -
REXML
:: XPath (11) - Shell (18)
-
Shell
:: CommandProcessor (6) -
Shell
:: Filter (6)
キーワード
-
NEWS for Ruby 2
. 5 . 0 (7) -
NEWS for Ruby 2
. 6 . 0 (6) -
NEWS for Ruby 2
. 7 . 0 (5) -
def
_ system _ command (6) -
each
_ child (22) -
each
_ entry (13) -
each
_ filename (11) -
each
_ line (22) - foreach (29)
-
install
_ system _ commands (6) -
ruby 1
. 6 feature (11) -
ruby 1
. 8 . 4 feature (11) -
to
_ a (11) -
webrick
/ cgi (11)
検索結果
先頭5件
- REXML
:: XPath . each(element , path = nil , namespaces = {} , variables = {}) {|e| . . . } -> () - REXML
:: Elements # each(xpath = nil) {|element| . . . } -> [REXML :: Elements] - Pathname
# each _ child(with _ directory = true) {|pathname| . . . } -> [Pathname] - Pathname
# each _ entry {|pathname| . . . } -> nil - Pathname
# each _ line(*args) -> Enumerator
-
REXML
:: XPath . each(element , path = nil , namespaces = {} , variables = {}) {|e| . . . } -> () (21248.0) -
element の path で指定した XPath 文字列にマッチする各ノード に対してブロックを呼び出します。
...element の path で指定した XPath 文字列にマッチする各ノード
に対してブロックを呼び出します。
path に相対パスを指定した場合は element からの相対位置で
マッチするノードを探します。
絶対パスを指定した場合は element が......ため、に用います。
@param element 要素(REXML::Element)
@param path XPath文字列
@param namespace 名前空間とURLの対応付け
@param variables 変数名とその値の対応付け
//emlist[][ruby]{
require 'rexml/document'
doc = REXML::Document.new(<<EOS)
<root xmlns:x='1'>
<a>......<b>b1</b>
<x:c />
<b>b2</b>
<d />
</a>
<b> b3 </b>
</root>
EOS
REXML::XPath.each(doc, "/root/a/b"){|e| p e.text }
# >> "b1"
# >> "b2"
//}... -
REXML
:: Elements # each(xpath = nil) {|element| . . . } -> [REXML :: Elements] (18243.0) -
全ての子要素に対しブロックを呼び出します。
...xpath を指定した場合には、その XPath 文字列に
マッチする要素に対しブロックを呼び出します。
REXML::XPath.each などとは異なり、要素以外の
テキストノードなどはすべて無視されることに注意してください。
@param xpath XPath......list[][ruby]{
require 'rexml/document'
require 'rexml/xpath'
doc = REXML::Document.new '<a><b/><c/><d/>sean<b/><c/><d/></a>'
# <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 }
//}... -
Pathname
# each _ child(with _ directory = true) {|pathname| . . . } -> [Pathname] (9336.0) -
self.children(with_directory).each と同じです。
...).each と同じです。
@param with_directory 偽を指定するとファイル名のみ返します。デフォルトは真です。
//emlist[例][ruby]{
require "pathname"
Pathname("/usr/local").each_child {|f| p f }
# => #<Pathname:/usr/local/bin>
# => #<Pathname:/usr/local/etc>
# => #<Pathn......# => #<Pathname:/usr/local/lib>
# => #<Pathname:/usr/local/opt>
# => #<Pathname:/usr/local/sbin>
# => #<Pathname:/usr/local/share>
# => #<Pathname:/usr/local/var>
Pathname("/usr/local").each_child(false) {|f| p f }
# => #<Pathname:bin>
# => #<Pathname:etc>
# => #<Pathname:include>
# => #<Pathname:l......ib>
# => #<Pathname:opt>
# => #<Pathname:sbin>
# => #<Pathname:share>
# => #<Pathname:var>
//}
@see Pathname#children... -
Pathname
# each _ entry {|pathname| . . . } -> nil (9214.0) -
Dir.foreach(self.to_s) {|f| yield Pathname.new(f) } と同じです。
...r.foreach(self.to_s) {|f| yield Pathname.new(f) } と同じです。
//emlist[例][ruby]{
require "pathname"
Pathname("/usr/local").each_entry {|f| p f }
# => #<Pathname:.>
# => #<Pathname:..>
# => #<Pathname:bin>
# => #<Pathname:etc>
# => #<Pathname:include>
# => #<Pathname:lib>
# => #<Pathname......:opt>
//}
@see Dir.foreach......r.foreach(self.to_s) {|f| yield Pathname.new(f) } と同じです。
ブロックを省略した場合は Enumerator を返します。
//emlist[例][ruby]{
require "pathname"
Pathname("/usr/local").each_entry {|f| p f }
# => #<Pathname:.>
# => #<Pathname:..>
# => #<Pathname:bin>
# => #<Pathname......:etc>
# => #<Pathname:include>
# => #<Pathname:lib>
# => #<Pathname:opt>
//}
@see Dir.foreach... -
Pathname
# each _ line(*args) -> Enumerator (9150.0) -
IO.foreach(self.to_s, *args, &block) と同じです。
...IO.foreach(self.to_s, *args, &block) と同じです。
//emlist[例][ruby]{
require "pathname"
IO.write("testfile", "line1\nline2,\nline3\n")
Pathname("testfile").each_line
# => #<Enumerator: IO:foreach("testfile")>
//}
//emlist[例 ブロックを指定][ruby]{
require "pathname"
IO.write("tes......tfile", "line1\nline2,\nline3\n")
Pathname("testfile").each_line {|f| p f }
# => "line1\n"
# => "line2,\n"
# => "line3\n"
//}
//emlist[例 limit を指定][ruby]{
require "pathname"
IO.write("testfile", "line1\nline2,\nline3\n")
Pathname("testfile").each_line(4) {|f| p f }
# => "line"
# => "1\n"......# => "line"
# => "2,\n"
# => "line"
# => "3\n"
//}
//emlist[例 sep を指定][ruby]{
require "pathname"
IO.write("testfile", "line1\nline2,\nline3\n")
Pathname("testfile").each_line(",") {|f| p f }
# => "line1\nline2,"
# => "\nline3\n"
//}
@see IO.foreach... -
Pathname
# each _ line(*args) {|line| . . . } -> nil (9150.0) -
IO.foreach(self.to_s, *args, &block) と同じです。
...IO.foreach(self.to_s, *args, &block) と同じです。
//emlist[例][ruby]{
require "pathname"
IO.write("testfile", "line1\nline2,\nline3\n")
Pathname("testfile").each_line
# => #<Enumerator: IO:foreach("testfile")>
//}
//emlist[例 ブロックを指定][ruby]{
require "pathname"
IO.write("tes......tfile", "line1\nline2,\nline3\n")
Pathname("testfile").each_line {|f| p f }
# => "line1\n"
# => "line2,\n"
# => "line3\n"
//}
//emlist[例 limit を指定][ruby]{
require "pathname"
IO.write("testfile", "line1\nline2,\nline3\n")
Pathname("testfile").each_line(4) {|f| p f }
# => "line"
# => "1\n"......# => "line"
# => "2,\n"
# => "line"
# => "3\n"
//}
//emlist[例 sep を指定][ruby]{
require "pathname"
IO.write("testfile", "line1\nline2,\nline3\n")
Pathname("testfile").each_line(",") {|f| p f }
# => "line1\nline2,"
# => "\nline3\n"
//}
@see IO.foreach... -
Pathname
# each _ child(with _ directory = true) -> Enumerator (9136.0) -
self.children(with_directory).each と同じです。
...).each と同じです。
@param with_directory 偽を指定するとファイル名のみ返します。デフォルトは真です。
//emlist[例][ruby]{
require "pathname"
Pathname("/usr/local").each_child {|f| p f }
# => #<Pathname:/usr/local/bin>
# => #<Pathname:/usr/local/etc>
# => #<Pathn......# => #<Pathname:/usr/local/lib>
# => #<Pathname:/usr/local/opt>
# => #<Pathname:/usr/local/sbin>
# => #<Pathname:/usr/local/share>
# => #<Pathname:/usr/local/var>
Pathname("/usr/local").each_child(false) {|f| p f }
# => #<Pathname:bin>
# => #<Pathname:etc>
# => #<Pathname:include>
# => #<Pathname:l......ib>
# => #<Pathname:opt>
# => #<Pathname:sbin>
# => #<Pathname:share>
# => #<Pathname:var>
//}
@see Pathname#children... -
Pathname
# each _ entry -> Enumerator (9114.0) -
Dir.foreach(self.to_s) {|f| yield Pathname.new(f) } と同じです。
...r.foreach(self.to_s) {|f| yield Pathname.new(f) } と同じです。
ブロックを省略した場合は Enumerator を返します。
//emlist[例][ruby]{
require "pathname"
Pathname("/usr/local").each_entry {|f| p f }
# => #<Pathname:.>
# => #<Pathname:..>
# => #<Pathname:bin>
# => #<Pathname......:etc>
# => #<Pathname:include>
# => #<Pathname:lib>
# => #<Pathname:opt>
//}
@see Dir.foreach... -
Pathname
# each _ filename {|v| . . . } -> nil (9113.0) -
self のパス名要素毎にブロックを実行します。
...self のパス名要素毎にブロックを実行します。
//emlist[例][ruby]{
require 'pathname'
Pathname.new("/foo/../bar").each_filename {|v| p v}
# => "foo"
# ".."
# "bar"
//}... -
Shell
# foreach(path = nil , &block) -> () (6245.0) -
pathがファイルなら, File#foreach pathがディレクトリなら, Dir#foreach の動作をします。
...
pathがファイルなら, File#foreach
pathがディレクトリなら, Dir#foreach
の動作をします。
@param path ファイルもしくはディレクトリのパスを文字列で指定します。
使用例
require 'shell'
Shell.verbose = false
sh = Shell.new
sh.foreach("/tmp"){... -
Shell
:: CommandProcessor # foreach(path = nil , &block) -> () (6245.0) -
pathがファイルなら, File#foreach pathがディレクトリなら, Dir#foreach の動作をします。
...
pathがファイルなら, File#foreach
pathがディレクトリなら, Dir#foreach
の動作をします。
@param path ファイルもしくはディレクトリのパスを文字列で指定します。
使用例
require 'shell'
Shell.verbose = false
sh = Shell.new
sh.foreach("/tmp"){...