種類
- インスタンスメソッド (200)
- モジュール関数 (165)
- クラス (20)
- 特異メソッド (11)
クラス
- Array (107)
- Enumerator (11)
- IO (44)
- Module (5)
- String (44)
モジュール
- Kernel (165)
キーワード
- ConditionVariable (9)
-
caller
_ locations (22) - combination (22)
-
const
_ source _ location (5) - encode (33)
- exec (44)
-
next
_ values (11) - pack (19)
- permutation (22)
- readlines (33)
-
repeated
_ combination (22) -
repeated
_ permutation (22) - select (22)
- spawn (44)
- system (44)
- unpack (11)
検索結果
先頭5件
-
IO (46398.0)
-
基本的な入出力機能のためのクラスです。
...基本的な入出力機能のためのクラスです。
File::Constants は、File から IO へ移動しました。
===[a:m17n] 多言語化と IO のエンコーディング
IO オブジェクトはエンコーディングを持ちます。
エンコーディングの影響を受けるメ......と受けないメソッドがあります。
影響を受けるメソッドでは、IO のエンコーディングに従い読み込まれた文字列のエンコーディングが決定されます。
また IO のエンコーディングを適切に設定することにより、読み込み時......ないメソッド
IO の読み込みメソッドは2種類存在します。
テキスト読み込みメソッドとバイナリ読み込みメソッドです。
テキスト読み込みメソッドは IO のエンコーディングの影響をうけます。
詳しくは「io_encoding」を参... -
IO
. select(reads , writes = [] , excepts = [] , timeout = nil) -> [[IO]] | nil (29351.0) -
select(2) を実行します。
...られた入力/出力/例外待ちの IO オブジェクトの中から準備ができたものを
それぞれ配列にして、配列の配列として返します。
タイムアウトした時には nil を返します。
@param reads 入力待ちする IO オブジェクトの配列を渡し......ます。
@param writes 出力待ちする IO オブジェクトの配列を渡します。
@param excepts 例外待ちする IO オブジェクトの配列を渡します。
@param timeout タイムアウトまでの時間を表す数値または nil を指定します。数値で指定したと......定した時には IO がどれかひとつレディ状態になるまで待ち続けます。
@raise IOError 与えられた IO オブジェクトが閉じられていた時に発生します。
@raise Errno::EXXX select(2) に失敗した場合に発生します。
rp, wp = IO.pipe
mesg = "pi... -
IO
# readlines(limit , chomp: false) -> [String] (29036.0) -
データを全て読み込んで、その各行を要素としてもつ配列を返します。 既に EOF に達していれば空配列 [] を返します。
...データを全て読み込んで、その各行を要素としてもつ配列を返します。
既に EOF に達していれば空配列 [] を返します。
テキスト読み込みメソッドとして動作します。
limit で最大読み込みバイト数を指定します。ただしマ......@param chomp true を指定すると各行の末尾から rs を取り除きます。
@raise IOError 自身が読み込み用にオープンされていなければ発生します。
//emlist[例][ruby]{
IO.write("testfile", "line1,\nline2,\nline3,\n")
File.open("testfile") { |f| p f.readlines }......chomp = true)][ruby]{
IO.write("testfile", "line1,\rline2,\r\nline3,\n")
File.open("testfile") { |f| p f.readlines(chomp: true) } # => ["line1,\rline2,", "line3,"]
File.open("testfile") { |f| p f.readlines("\r", chomp: true) } # => ["line1,", "line2,", "\nline3,\n"]
//}
@see $/, IO#gets... -
IO
# readlines(rs = $ / , chomp: false) -> [String] (29036.0) -
データを全て読み込んで、その各行を要素としてもつ配列を返します。 既に EOF に達していれば空配列 [] を返します。
...データを全て読み込んで、その各行を要素としてもつ配列を返します。
既に EOF に達していれば空配列 [] を返します。
テキスト読み込みメソッドとして動作します。
limit で最大読み込みバイト数を指定します。ただしマ......@param chomp true を指定すると各行の末尾から rs を取り除きます。
@raise IOError 自身が読み込み用にオープンされていなければ発生します。
//emlist[例][ruby]{
IO.write("testfile", "line1,\nline2,\nline3,\n")
File.open("testfile") { |f| p f.readlines }......chomp = true)][ruby]{
IO.write("testfile", "line1,\rline2,\r\nline3,\n")
File.open("testfile") { |f| p f.readlines(chomp: true) } # => ["line1,\rline2,", "line3,"]
File.open("testfile") { |f| p f.readlines("\r", chomp: true) } # => ["line1,", "line2,", "\nline3,\n"]
//}
@see $/, IO#gets... -
IO
# readlines(rs , limit , chomp: false) -> [String] (29036.0) -
データを全て読み込んで、その各行を要素としてもつ配列を返します。 既に EOF に達していれば空配列 [] を返します。
...データを全て読み込んで、その各行を要素としてもつ配列を返します。
既に EOF に達していれば空配列 [] を返します。
テキスト読み込みメソッドとして動作します。
limit で最大読み込みバイト数を指定します。ただしマ......@param chomp true を指定すると各行の末尾から rs を取り除きます。
@raise IOError 自身が読み込み用にオープンされていなければ発生します。
//emlist[例][ruby]{
IO.write("testfile", "line1,\nline2,\nline3,\n")
File.open("testfile") { |f| p f.readlines }......chomp = true)][ruby]{
IO.write("testfile", "line1,\rline2,\r\nline3,\n")
File.open("testfile") { |f| p f.readlines(chomp: true) } # => ["line1,\rline2,", "line3,"]
File.open("testfile") { |f| p f.readlines("\r", chomp: true) } # => ["line1,", "line2,", "\nline3,\n"]
//}
@see $/, IO#gets... -
IO
# readlines(limit) -> [String] (29030.0) -
データを全て読み込んで、その各行を要素としてもつ配列を返します。 既に EOF に達していれば空配列 [] を返します。
...データを全て読み込んで、その各行を要素としてもつ配列を返します。
既に EOF に達していれば空配列 [] を返します。
テキスト読み込みメソッドとして動作します。
limit で最大読み込みバイト数を指定します。ただしマ......します(パラグラフモード)。
@param limit 最大の読み込みバイト数
@raise IOError 自身が読み込み用にオープンされていなければ発生します。
//emlist[例][ruby]{
IO.write("testfile", "line1,\nline2,\nline3,\n")
File.open("testfile") { |f| p f.readlines }......# => ["line1,\n", "line2,\n", "line3,\n"]
File.open("testfile") { |f| p f.readlines(3) } # => ["lin", "e1,", "\n", "lin", "e2,", "\n", "lin", "e3,", "\n"]
File.open("testfile") { |f| p f.readlines(",") } # => ["line1,", "\nline2,", "\nline3,", "\n"]
//}
@see $/, IO#gets... -
IO
# readlines(rs = $ / ) -> [String] (29030.0) -
データを全て読み込んで、その各行を要素としてもつ配列を返します。 既に EOF に達していれば空配列 [] を返します。
...データを全て読み込んで、その各行を要素としてもつ配列を返します。
既に EOF に達していれば空配列 [] を返します。
テキスト読み込みメソッドとして動作します。
limit で最大読み込みバイト数を指定します。ただしマ......します(パラグラフモード)。
@param limit 最大の読み込みバイト数
@raise IOError 自身が読み込み用にオープンされていなければ発生します。
//emlist[例][ruby]{
IO.write("testfile", "line1,\nline2,\nline3,\n")
File.open("testfile") { |f| p f.readlines }......# => ["line1,\n", "line2,\n", "line3,\n"]
File.open("testfile") { |f| p f.readlines(3) } # => ["lin", "e1,", "\n", "lin", "e2,", "\n", "lin", "e3,", "\n"]
File.open("testfile") { |f| p f.readlines(",") } # => ["line1,", "\nline2,", "\nline3,", "\n"]
//}
@see $/, IO#gets... -
IO
# readlines(rs , limit) -> [String] (29030.0) -
データを全て読み込んで、その各行を要素としてもつ配列を返します。 既に EOF に達していれば空配列 [] を返します。
...データを全て読み込んで、その各行を要素としてもつ配列を返します。
既に EOF に達していれば空配列 [] を返します。
テキスト読み込みメソッドとして動作します。
limit で最大読み込みバイト数を指定します。ただしマ......します(パラグラフモード)。
@param limit 最大の読み込みバイト数
@raise IOError 自身が読み込み用にオープンされていなければ発生します。
//emlist[例][ruby]{
IO.write("testfile", "line1,\nline2,\nline3,\n")
File.open("testfile") { |f| p f.readlines }......# => ["line1,\n", "line2,\n", "line3,\n"]
File.open("testfile") { |f| p f.readlines(3) } # => ["lin", "e1,", "\n", "lin", "e2,", "\n", "lin", "e3,", "\n"]
File.open("testfile") { |f| p f.readlines(",") } # => ["line1,", "\nline2,", "\nline3,", "\n"]
//}
@see $/, IO#gets... -
Kernel
. # caller _ locations(range) -> [Thread :: Backtrace :: Location] | nil (14208.0) -
現在のフレームを Thread::Backtrace::Location の配列で返します。引 数で指定した値が範囲外の場合は nil を返します。
...現在のフレームを Thread::Backtrace::Location の配列で返します。引
数で指定した値が範囲外の場合は nil を返します。
@param start 開始フレームの位置を数値で指定します。
@param length 取得するフレームの個数を指定します。
@pa......test1(start, length)
locations = caller_locations(start, length)
p locations
p locations.map(&:lineno)
p locations.map(&:path)
end
def test2(start, length)
test1(start, length)
end
def test3(start, length)
test2(start, length)
end
caller_locations # => []
test3(1, nil)
# => ["/Users/......(1, 2)
# => ["/Users/user/test.rb:9:in `test2'", "/Users/user/test.rb:13:in `test3'"]
# => [9, 13]
# => ["/Users/user/test.rb", "/Users/user/test.rb"]
test3(2, 1)
# => ["/Users/user/test.rb:13:in `test3'"]
# => [13]
# => ["/Users/user/test.rb"]
//}
@see Thread::Backtrace::Location, Kernel.#caller... -
Kernel
. # caller _ locations(start = 1 , length = nil) -> [Thread :: Backtrace :: Location] | nil (14208.0) -
現在のフレームを Thread::Backtrace::Location の配列で返します。引 数で指定した値が範囲外の場合は nil を返します。
...現在のフレームを Thread::Backtrace::Location の配列で返します。引
数で指定した値が範囲外の場合は nil を返します。
@param start 開始フレームの位置を数値で指定します。
@param length 取得するフレームの個数を指定します。
@pa......test1(start, length)
locations = caller_locations(start, length)
p locations
p locations.map(&:lineno)
p locations.map(&:path)
end
def test2(start, length)
test1(start, length)
end
def test3(start, length)
test2(start, length)
end
caller_locations # => []
test3(1, nil)
# => ["/Users/......(1, 2)
# => ["/Users/user/test.rb:9:in `test2'", "/Users/user/test.rb:13:in `test3'"]
# => [9, 13]
# => ["/Users/user/test.rb", "/Users/user/test.rb"]
test3(2, 1)
# => ["/Users/user/test.rb:13:in `test3'"]
# => [13]
# => ["/Users/user/test.rb"]
//}
@see Thread::Backtrace::Location, Kernel.#caller... -
Array
# combination(n) -> Enumerator (14114.0) -
サイズ n の組み合わせをすべて生成し、それを引数としてブロックを実行します。
...bination(1).to_a #=> [[1],[2],[3],[4]]
a.combination(2).to_a #=> [[1,2],[1,3],[1,4],[2,3],[2,4],[3,4]]
a.combination(3).to_a #=> [[1,2,3],[1,2,4],[1,3,4],[2,3,4]]
a.combination(4).to_a #=> [[1,2,3,4]]
a.combination(0).to_a #=> [[]]: one combination of length 0
a.combination(5).to_a #=> [] : n......o combinations of length 5
//}
ブロックが与えられた場合、作成した配列の各要素を引数としてブロックを実
行して self を返します。
//emlist[例][ruby]{
a = [1, 2, 3, 4]
result = []
a.combination(2) {|e| result << e} # => [1,2,3,4]
result #=> [[1,2],[1,3],[1,......4],[2,3],[2,4],[3,4]]
//}
@see Array#permutation, Array#repeated_combination... -
Array
# combination(n) {|c| block } -> self (14114.0) -
サイズ n の組み合わせをすべて生成し、それを引数としてブロックを実行します。
...bination(1).to_a #=> [[1],[2],[3],[4]]
a.combination(2).to_a #=> [[1,2],[1,3],[1,4],[2,3],[2,4],[3,4]]
a.combination(3).to_a #=> [[1,2,3],[1,2,4],[1,3,4],[2,3,4]]
a.combination(4).to_a #=> [[1,2,3,4]]
a.combination(0).to_a #=> [[]]: one combination of length 0
a.combination(5).to_a #=> [] : n......o combinations of length 5
//}
ブロックが与えられた場合、作成した配列の各要素を引数としてブロックを実
行して self を返します。
//emlist[例][ruby]{
a = [1, 2, 3, 4]
result = []
a.combination(2) {|e| result << e} # => [1,2,3,4]
result #=> [[1,2],[1,3],[1,......4],[2,3],[2,4],[3,4]]
//}
@see Array#permutation, Array#repeated_combination... -
Array
# permutation(n = self . length) -> Enumerator (14114.0) -
サイズ n の順列をすべて生成し,それを引数としてブロックを実行します。
...ation.to_a #=> [[1,2,3],[1,3,2],[2,1,3],[2,3,1],[3,1,2],[3,2,1]]
a.permutation(1).to_a #=> [[1],[2],[3]]
a.permutation(2).to_a #=> [[1,2],[1,3],[2,1],[2,3],[3,1],[3,2]]
a.permutation(3).to_a #=> [[1,2,3],[1,3,2],[2,1,3],[2,3,1],[3,1,2],[3,2,1]]
a.permutation(0).to_a #=> [[]]: one permutation......of length 0
a.permutation(4).to_a #=> [] : no permutations of length 4
//}
ブロックが与えられた場合、作成した配列の各要素を引数としてブロックを実
行して self を返します。
//emlist[例][ruby]{
a = [1, 2, 3]
result = []
a.permutation(2) {|e| result << e}......# => [1,2,3]
result # => [[1,2],[1,3],[2,1],[2,3],[3,1],[3,2]]
//}
@see Array#combination, Array#repeated_permutation...