176件ヒット
[1-100件を表示]
(0.077秒)
ライブラリ
- ビルトイン (176)
検索結果
先頭5件
-
Dir
# read -> String | nil (6138.0) -
ディレクトリストリームから次の要素を読み出して返します。最後の要素 まで読み出していれば nil を返します。
...equire 'tmpdir'
Dir.mktmpdir do |tmpdir|
File.open("#{tmpdir}/test1.txt", "w") { |f| f.puts("test1") }
File.open("#{tmpdir}/test2.txt", "w") { |f| f.puts("test2") }
Dir.open(tmpdir) do |d|
p d.read # => "."
p d.read # => ".."
p d.read # => "test1.txt"
p d.read # => "te......st2.txt"
p d.read # => nil
end
end
//}... -
Dir
# rewind -> self (6126.0) -
ディレクトリストリームの読み込み位置を先頭に移動させます。
...レクトリストリームの読み込み位置を先頭に移動させます。
@raise IOError 既に自身が close している場合に発生します。
//emlist[例][ruby]{
Dir.open("testdir") do |d|
d.read # => "."
d.rewind # => #<Dir:0x401b3fb0>
d.read # => "."
end
//}... -
Dir
# children -> [String] (6114.0) -
ディレクトリのファイルエントリ名のうち、 "." と ".." をのぞいた配列を返します。
...ディレクトリのファイルエントリ名のうち、
"." と ".." をのぞいた配列を返します。
@raise IOError 既に self が close している場合に発生します。
//emlist[例][ruby]{
Dir.open('.'){|d|
p d.children # => ["bar", "foo"]
}
//}
@see Dir.children... -
Dir
# each _ child -> Enumerator (6102.0) -
ディレクトリの "." と ".." をのぞく各エントリを表す文字列を引数として、 ブロックを評価します。
...合、各エントリを文字列として保持する
Enumerator
オブジェクトを返します。
@raise IOError 既に self が close している場合に発生します。
//emlist[例][ruby]{
Dir.open('.').each_child{|f|
p f
}
#=> "bar"
# "foo"
//}
@see Dir#each
@see Dir.each_child... -
Dir
# each _ child {|item| . . . } -> self (6102.0) -
ディレクトリの "." と ".." をのぞく各エントリを表す文字列を引数として、 ブロックを評価します。
...合、各エントリを文字列として保持する
Enumerator
オブジェクトを返します。
@raise IOError 既に self が close している場合に発生します。
//emlist[例][ruby]{
Dir.open('.').each_child{|f|
p f
}
#=> "bar"
# "foo"
//}
@see Dir#each
@see Dir.each_child... -
Dir
# pos=(pos) (3038.0) -
ディレクトリストリームの読み込み位置を pos に移動させます。 pos は Dir#tell で与えられた値でなければなりま せん。
... Dir#tell で与えられた値でなければなりま
せん。
@param pos 変更したい位置を整数で与えます。
@raise IOError 既に自身が close している場合に発生します。
//emlist[例][ruby]{
Dir.open("testdir") do |d|
d.read # => "."
i = d.te......ll # => 12
d.read # => ".."
d.seek(i) # => #<Dir:0x401b3c40>
d.read # => ".."
end
//}... -
Dir
# seek(pos) -> self (3038.0) -
ディレクトリストリームの読み込み位置を pos に移動させます。 pos は Dir#tell で与えられた値でなければなりま せん。
... Dir#tell で与えられた値でなければなりま
せん。
@param pos 変更したい位置を整数で与えます。
@raise IOError 既に自身が close している場合に発生します。
//emlist[例][ruby]{
Dir.open("testdir") do |d|
d.read # => "."
i = d.te......ll # => 12
d.read # => ".."
d.seek(i) # => #<Dir:0x401b3c40>
d.read # => ".."
end
//}... -
Dir
# path -> String (3020.0) -
オープンしているディレクトリのパス名を文字列で返します。
...オープンしているディレクトリのパス名を文字列で返します。
//emlist[例][ruby]{
Dir.open("..") do |d|
d.path # => ".."
d.to_path # => ".."
end
//}... -
Dir
# pos -> Integer (3020.0) -
ディレクトリストリームの現在の位置を整数で返します。
...ディレクトリストリームの現在の位置を整数で返します。
@raise IOError 既に自身が close している場合に発生します。
//emlist[例][ruby]{
Dir.open("/tmp") {|d|
d.each {|f|
p d.pos
}
}
//}... -
Dir
# tell -> Integer (3020.0) -
ディレクトリストリームの現在の位置を整数で返します。
...ディレクトリストリームの現在の位置を整数で返します。
@raise IOError 既に自身が close している場合に発生します。
//emlist[例][ruby]{
Dir.open("/tmp") {|d|
d.each {|f|
p d.pos
}
}
//}...