64件ヒット
[1-64件を表示]
(0.083秒)
ライブラリ
- ビルトイン (11)
- pathname (35)
- shell (6)
-
shell
/ command-processor (6) -
shell
/ filter (6)
クラス
- Pathname (35)
- Shell (6)
-
Shell
:: CommandProcessor (6) -
Shell
:: Filter (6)
モジュール
- Enumerable (11)
キーワード
- chunk (11)
-
each
_ entry (13) -
each
_ line (22)
検索結果
先頭5件
-
Shell
# foreach(path = nil , &block) -> () (18140.0) -
pathがファイルなら, File#foreach pathがディレクトリなら, Dir#foreach の動作をします。
...イルなら, File#foreach
pathがディレクトリなら, Dir#foreach
の動作をします。
@param path ファイルもしくはディレクトリのパスを文字列で指定します。
使用例
require 'shell'
Shell.verbose = false
sh = Shell.new
sh.foreach("/tmp"){|f|
puts f... -
Shell
:: CommandProcessor # foreach(path = nil , &block) -> () (18140.0) -
pathがファイルなら, File#foreach pathがディレクトリなら, Dir#foreach の動作をします。
...イルなら, File#foreach
pathがディレクトリなら, Dir#foreach
の動作をします。
@param path ファイルもしくはディレクトリのパスを文字列で指定します。
使用例
require 'shell'
Shell.verbose = false
sh = Shell.new
sh.foreach("/tmp"){|f|
puts f... -
Shell
:: Filter # foreach(path = nil , &block) -> () (18140.0) -
pathがファイルなら, File#foreach pathがディレクトリなら, Dir#foreach の動作をします。
...イルなら, File#foreach
pathがディレクトリなら, Dir#foreach
の動作をします。
@param path ファイルもしくはディレクトリのパスを文字列で指定します。
使用例
require 'shell'
Shell.verbose = false
sh = Shell.new
sh.foreach("/tmp"){|f|
puts f... -
Pathname
# each _ line(*args) -> Enumerator (29.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......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 (29.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......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 _ entry -> Enumerator (23.0) -
Dir.foreach(self.to_s) {|f| yield Pathname.new(f) } と同じです。
...Dir.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>
# => #<Pathna......me:etc>
# => #<Pathname:include>
# => #<Pathname:lib>
# => #<Pathname:opt>
//}
@see Dir.foreach... -
Pathname
# each _ entry {|pathname| . . . } -> nil (23.0) -
Dir.foreach(self.to_s) {|f| yield Pathname.new(f) } と同じです。
...Dir.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>
# => #<Pathna......me:opt>
//}
@see Dir.foreach......Dir.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>
# => #<Pathna......me:etc>
# => #<Pathname:include>
# => #<Pathname:lib>
# => #<Pathname:opt>
//}
@see Dir.foreach... -
Enumerable
# chunk {|elt| . . . } -> Enumerator (7.0) -
要素を前から順にブロックで評価し、その結果によって 要素をチャンクに分けた(グループ化した)要素を持つ Enumerator を返します。
...# "\n"]
# ...
//}
テキストを空行で区切られた段落に分けたい場合にも nil が使えます。
//emlist[例][ruby]{
File.foreach("README").chunk {|line|
/\A\s*\z/ !~ line || nil
}.each {|_, lines|
pp lines
}
//}
「:_alone」は要素を素通ししたい場合に用...