るりまサーチ

最速Rubyリファレンスマニュアル検索!
868件ヒット [801-868件を表示] (0.057秒)

別のキーワード

  1. _builtin >
  2. bigdecimal >
  3. float >
  4. module >
  5. integer >

ライブラリ

モジュール

キーワード

検索結果

<< < ... 7 8 9 >>

IO.popen("-", mode = "r", opt={}) {|io| ... } -> object (104.0)

第一引数に文字列 "-" が指定された時、fork(2) を 行い子プロセスの標準入出力との間にパイプラインを確立します。 親プロセスでは IO オブジェクトを返し、子プロセスでは nil を返します。

...し、子プロセスでは
nil を返します。

io = IO.popen("-", "r+")
if io # parent
io.puts "foo"
p io.gets # => "child output: foo\n"
io.close
else # child
s = gets
print "child output: " + s
exit
end

ブロックを与えられた場...
...=> "child output: foo\n"

opt ではエンコーディングの設定やプロセス起動のためのオプションが指定できます。
IO.new や Kernel.#spawn で指定できるものと共通なので
詳しくはそちらを見てください。

@param env 環境変数を { 変数名 =>...

IO.popen(env, "-", mode = "r", opt={}) -> IO (104.0)

第一引数に文字列 "-" が指定された時、fork(2) を 行い子プロセスの標準入出力との間にパイプラインを確立します。 親プロセスでは IO オブジェクトを返し、子プロセスでは nil を返します。

...し、子プロセスでは
nil を返します。

io = IO.popen("-", "r+")
if io # parent
io.puts "foo"
p io.gets # => "child output: foo\n"
io.close
else # child
s = gets
print "child output: " + s
exit
end

ブロックを与えられた場...
...=> "child output: foo\n"

opt ではエンコーディングの設定やプロセス起動のためのオプションが指定できます。
IO.new や Kernel.#spawn で指定できるものと共通なので
詳しくはそちらを見てください。

@param env 環境変数を { 変数名 =>...

IO.popen(env, "-", mode = "r", opt={}) {|io| ... } -> object (104.0)

第一引数に文字列 "-" が指定された時、fork(2) を 行い子プロセスの標準入出力との間にパイプラインを確立します。 親プロセスでは IO オブジェクトを返し、子プロセスでは nil を返します。

...し、子プロセスでは
nil を返します。

io = IO.popen("-", "r+")
if io # parent
io.puts "foo"
p io.gets # => "child output: foo\n"
io.close
else # child
s = gets
print "child output: " + s
exit
end

ブロックを与えられた場...
...=> "child output: foo\n"

opt ではエンコーディングの設定やプロセス起動のためのオプションが指定できます。
IO.new や Kernel.#spawn で指定できるものと共通なので
詳しくはそちらを見てください。

@param env 環境変数を { 変数名 =>...

CSV.filter(input, options = Hash.new) {|row| ... } (25.0)

このメソッドは CSV データに対して Unix のツール群のようなフィルタを構築 するのに便利です。

...o "header1,header2\nrow1_1,row1_2" > in.csv; ruby test.rb in.csv

require "csv"

options = { headers: true, return_headers: true, write_headers: true }

CSV.filter(options) do |row|
if row.header_row?
row << "header3"
next
end
row << "row1_3"
end

# => header1,header2,header3
# row1_1,...
...<<EOS
id,first name,last name,age
1,taro,tanaka,20
2,jiro,suzuki,18
3,ami,sato,19
4,yumi,adachi,21
EOS

File.write('test.csv',content)
options = { headers: true, return_headers: true, write_headers: true }

CSV.filter(File.open("test.csv"), File.open("out.csv", "w"), options) do |row|
if row.head...
...er_row?
row << "full name"
next
end
row << row["first name"] + " " + row["last name"]
end

# out.csv の内容
# => id,first name,last name,age,full name
# 1,taro,tanaka,20,taro tanaka
# 2,jiro,suzuki,18,jiro suzuki
# 3,ami,sato,19,ami sato
# 4,yumi,adachi,21,yumi adachi
//}...

CSV.filter(input, output, options = Hash.new) {|row| ... } (25.0)

このメソッドは CSV データに対して Unix のツール群のようなフィルタを構築 するのに便利です。

...o "header1,header2\nrow1_1,row1_2" > in.csv; ruby test.rb in.csv

require "csv"

options = { headers: true, return_headers: true, write_headers: true }

CSV.filter(options) do |row|
if row.header_row?
row << "header3"
next
end
row << "row1_3"
end

# => header1,header2,header3
# row1_1,...
...<<EOS
id,first name,last name,age
1,taro,tanaka,20
2,jiro,suzuki,18
3,ami,sato,19
4,yumi,adachi,21
EOS

File.write('test.csv',content)
options = { headers: true, return_headers: true, write_headers: true }

CSV.filter(File.open("test.csv"), File.open("out.csv", "w"), options) do |row|
if row.head...
...er_row?
row << "full name"
next
end
row << row["first name"] + " " + row["last name"]
end

# out.csv の内容
# => id,first name,last name,age,full name
# 1,taro,tanaka,20,taro tanaka
# 2,jiro,suzuki,18,jiro suzuki
# 3,ami,sato,19,ami sato
# 4,yumi,adachi,21,yumi adachi
//}...

絞り込み条件を変える

CSV.filter(options = Hash.new) {|row| ... } (25.0)

このメソッドは CSV データに対して Unix のツール群のようなフィルタを構築 するのに便利です。

...o "header1,header2\nrow1_1,row1_2" > in.csv; ruby test.rb in.csv

require "csv"

options = { headers: true, return_headers: true, write_headers: true }

CSV.filter(options) do |row|
if row.header_row?
row << "header3"
next
end
row << "row1_3"
end

# => header1,header2,header3
# row1_1,...
...<<EOS
id,first name,last name,age
1,taro,tanaka,20
2,jiro,suzuki,18
3,ami,sato,19
4,yumi,adachi,21
EOS

File.write('test.csv',content)
options = { headers: true, return_headers: true, write_headers: true }

CSV.filter(File.open("test.csv"), File.open("out.csv", "w"), options) do |row|
if row.head...
...er_row?
row << "full name"
next
end
row << row["first name"] + " " + row["last name"]
end

# out.csv の内容
# => id,first name,last name,age,full name
# 1,taro,tanaka,20,taro tanaka
# 2,jiro,suzuki,18,jiro suzuki
# 3,ami,sato,19,ami sato
# 4,yumi,adachi,21,yumi adachi
//}...
<< < ... 7 8 9 >>