るりまサーチ

最速Rubyリファレンスマニュアル検索!
833件ヒット [301-400件を表示] (0.024秒)
トップページ > クラス:IO[x] > クエリ:write[x]

別のキーワード

  1. rexml/document write
  2. _builtin write
  3. io write
  4. tuple write
  5. stringio write

ライブラリ

キーワード

検索結果

<< < ... 2 3 4 5 6 ... > >>

IO#each_line(rs = $/) {|line| ... } -> self (13.0)

IO の現在位置から 1 行ずつ文字列として読み込み、それを引数として 与えられたブロックを実行します。

...
IO
の現在位置から 1 行ずつ文字列として読み込み、それを引数として
与えられたブロックを実行します。

ブロックが与えられなかった場合は、自身から生成した
Enumerator オブジェクトを返します。

テキスト読み込みメソ...
...パラグラフモード)。
@param limit 最大の読み込みバイト数

@raise IOError 自身が読み込み用にオープンされていなければ発生します。

//emlist[例: 引数なし][ruby]{
IO
.write("testfile", "This is line one,\nThis is line two,\nThis is line three,\nAnd so on...
...is line three,\n"
# "4: And so on..."
//}
//emlist[例: 行の区切りに半角カンマ、最大読み取りバイト数に 10 を指定][ruby]{
IO
.write("testfile", "This is line one,This is line two,This is line three,And so on...")
f = File.new("testfile")
f.each(",", 10) { |line| p "#{f.lineno...

IO#each_line(rs, limit) -> Enumerator (13.0)

IO の現在位置から 1 行ずつ文字列として読み込み、それを引数として 与えられたブロックを実行します。

...
IO
の現在位置から 1 行ずつ文字列として読み込み、それを引数として
与えられたブロックを実行します。

ブロックが与えられなかった場合は、自身から生成した
Enumerator オブジェクトを返します。

テキスト読み込みメソ...
...パラグラフモード)。
@param limit 最大の読み込みバイト数

@raise IOError 自身が読み込み用にオープンされていなければ発生します。

//emlist[例: 引数なし][ruby]{
IO
.write("testfile", "This is line one,\nThis is line two,\nThis is line three,\nAnd so on...
...is line three,\n"
# "4: And so on..."
//}
//emlist[例: 行の区切りに半角カンマ、最大読み取りバイト数に 10 を指定][ruby]{
IO
.write("testfile", "This is line one,This is line two,This is line three,And so on...")
f = File.new("testfile")
f.each(",", 10) { |line| p "#{f.lineno...

IO#each_line(rs, limit) {|line| ... } -> self (13.0)

IO の現在位置から 1 行ずつ文字列として読み込み、それを引数として 与えられたブロックを実行します。

...
IO
の現在位置から 1 行ずつ文字列として読み込み、それを引数として
与えられたブロックを実行します。

ブロックが与えられなかった場合は、自身から生成した
Enumerator オブジェクトを返します。

テキスト読み込みメソ...
...パラグラフモード)。
@param limit 最大の読み込みバイト数

@raise IOError 自身が読み込み用にオープンされていなければ発生します。

//emlist[例: 引数なし][ruby]{
IO
.write("testfile", "This is line one,\nThis is line two,\nThis is line three,\nAnd so on...
...is line three,\n"
# "4: And so on..."
//}
//emlist[例: 行の区切りに半角カンマ、最大読み取りバイト数に 10 を指定][ruby]{
IO
.write("testfile", "This is line one,This is line two,This is line three,And so on...")
f = File.new("testfile")
f.each(",", 10) { |line| p "#{f.lineno...

IO#readlines(limit, chomp: false) -> [String] (13.0)

データを全て読み込んで、その各行を要素としてもつ配列を返します。 既に EOF に達していれば空配列 [] を返します。

...ram 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] (13.0)

データを全て読み込んで、その各行を要素としてもつ配列を返します。 既に EOF に達していれば空配列 [] を返します。

...ram 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] (13.0)

データを全て読み込んで、その各行を要素としてもつ配列を返します。 既に EOF に達していれば空配列 [] を返します。

...ram 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#set_encoding_by_bom -> Encoding | nil (13.0)

BOM から IO のエンコーディングを設定します。

...BOM から IO のエンコーディングを設定します。

自身が BOM から始まる場合、BOM を読み進めて外部エンコーディングをセットし、セットしたエンコーディングを返します。
BOM が見つからなかった場合は nil を返します。

...
...//emlist[例][ruby]{
File.write("bom.txt", "\u{FEFF}abc")
File.open("bom.txt", "rb") do |io|
p io.set_encoding_by_bom #=> #<Encoding:UTF-8>
str = io.read
p str #=> "abc"
p str.encoding #=> #<Encoding:UTF-8>
end

File.write("nobom.txt", "abc")
File.o...
...pen("nobom.txt", "rb") do |io|
p io.set_encoding_by_bom #=> nil
end
//}...

IO.foreach(path, rs = $/) -> Enumerator (13.0)

path で指定されたファイルの各行を引数としてブロックを繰り返し実行します。 path のオープンに成功すれば nil を返します。

...ruby]{
IO
.write("testfile", "line1\nline2,\nline3\n")
IO
.foreach("testfile") # => #<Enumerator: IO:foreach("testfile")>
IO
.foreach("testfile") { |x| print "GOT ", x }
# => GOT line1
# GOT line2,
# GOT line3
//}

//emlist[例:カンマを行の区切りに指定( rs = "," )][ruby]{
IO
.write("tes...
...tfile", "line1,line2,line3")
IO
.foreach("testfile", ",") { |x| puts "GOT #{x}" }
# => GOT line1,
# GOT line2,
# GOT line3
//}


@see $/...

IO.foreach(path, rs = $/) {|line| ... } -> nil (13.0)

path で指定されたファイルの各行を引数としてブロックを繰り返し実行します。 path のオープンに成功すれば nil を返します。

...ruby]{
IO
.write("testfile", "line1\nline2,\nline3\n")
IO
.foreach("testfile") # => #<Enumerator: IO:foreach("testfile")>
IO
.foreach("testfile") { |x| print "GOT ", x }
# => GOT line1
# GOT line2,
# GOT line3
//}

//emlist[例:カンマを行の区切りに指定( rs = "," )][ruby]{
IO
.write("tes...
...tfile", "line1,line2,line3")
IO
.foreach("testfile", ",") { |x| puts "GOT #{x}" }
# => GOT line1,
# GOT line2,
# GOT line3
//}


@see $/...

IO.popen([env = {}, [cmdname, arg0], *args, execopt={}], mode = "r", opt={}) -> IO (13.0)

サブプロセスを実行し、そのプロセスの標準入出力 との間にパイプラインを確立します。生成したパイプを IO オブジェクトとして返します。

...出力
との間にパイプラインを確立します。生成したパイプを IO オブジェクトとして返します。

p io = IO.popen("cat", "r+") # => #<IO:fd 4>
io
.puts "foo"
io
.close_write
p io.gets # => "foo\n"

サブプロセスを指定する方法は2...
...生成した IO オブジェクトを引数にブ
ロックを実行し、ブロックの実行結果を返します。ブロックの実行後、生成したパイ
プは自動的にクローズされます。

p IO.popen("cat", "r+") {|io|
io
.puts "foo"
io
.close_write
io
.gets
}
#...
...ョンや、パイプ IO オブジェクトの属性(エンコーディングや
読み書き能力)を指定することができます。
プロセス起動のためのオプションは Kernel.#spawn と、
パイプオブジェクトの属性の指定のオプションは IO.new と共通です...

絞り込み条件を変える

IO.popen([env = {}, [cmdname, arg0], *args, execopt={}], mode = "r", opt={}) {|f| ... } -> object (13.0)

サブプロセスを実行し、そのプロセスの標準入出力 との間にパイプラインを確立します。生成したパイプを IO オブジェクトとして返します。

...出力
との間にパイプラインを確立します。生成したパイプを IO オブジェクトとして返します。

p io = IO.popen("cat", "r+") # => #<IO:fd 4>
io
.puts "foo"
io
.close_write
p io.gets # => "foo\n"

サブプロセスを指定する方法は2...
...生成した IO オブジェクトを引数にブ
ロックを実行し、ブロックの実行結果を返します。ブロックの実行後、生成したパイ
プは自動的にクローズされます。

p IO.popen("cat", "r+") {|io|
io
.puts "foo"
io
.close_write
io
.gets
}
#...
...ョンや、パイプ IO オブジェクトの属性(エンコーディングや
読み書き能力)を指定することができます。
プロセス起動のためのオプションは Kernel.#spawn と、
パイプオブジェクトの属性の指定のオプションは IO.new と共通です...

IO.popen([env = {}, cmdname, *args, execopt={}], mode = "r", opt={}) -> IO (13.0)

サブプロセスを実行し、そのプロセスの標準入出力 との間にパイプラインを確立します。生成したパイプを IO オブジェクトとして返します。

...出力
との間にパイプラインを確立します。生成したパイプを IO オブジェクトとして返します。

p io = IO.popen("cat", "r+") # => #<IO:fd 4>
io
.puts "foo"
io
.close_write
p io.gets # => "foo\n"

サブプロセスを指定する方法は2...
...生成した IO オブジェクトを引数にブ
ロックを実行し、ブロックの実行結果を返します。ブロックの実行後、生成したパイ
プは自動的にクローズされます。

p IO.popen("cat", "r+") {|io|
io
.puts "foo"
io
.close_write
io
.gets
}
#...
...ョンや、パイプ IO オブジェクトの属性(エンコーディングや
読み書き能力)を指定することができます。
プロセス起動のためのオプションは Kernel.#spawn と、
パイプオブジェクトの属性の指定のオプションは IO.new と共通です...

IO.popen([env = {}, cmdname, *args, execopt={}], mode = "r", opt={}) {|f| ... } -> object (13.0)

サブプロセスを実行し、そのプロセスの標準入出力 との間にパイプラインを確立します。生成したパイプを IO オブジェクトとして返します。

...出力
との間にパイプラインを確立します。生成したパイプを IO オブジェクトとして返します。

p io = IO.popen("cat", "r+") # => #<IO:fd 4>
io
.puts "foo"
io
.close_write
p io.gets # => "foo\n"

サブプロセスを指定する方法は2...
...生成した IO オブジェクトを引数にブ
ロックを実行し、ブロックの実行結果を返します。ブロックの実行後、生成したパイ
プは自動的にクローズされます。

p IO.popen("cat", "r+") {|io|
io
.puts "foo"
io
.close_write
io
.gets
}
#...
...ョンや、パイプ IO オブジェクトの属性(エンコーディングや
読み書き能力)を指定することができます。
プロセス起動のためのオプションは Kernel.#spawn と、
パイプオブジェクトの属性の指定のオプションは IO.new と共通です...

IO.popen(env = {}, [[cmdname, arg0], *args, execopt={}], mode = "r", opt={}) -> IO (13.0)

サブプロセスを実行し、そのプロセスの標準入出力 との間にパイプラインを確立します。生成したパイプを IO オブジェクトとして返します。

...出力
との間にパイプラインを確立します。生成したパイプを IO オブジェクトとして返します。

p io = IO.popen("cat", "r+") # => #<IO:fd 4>
io
.puts "foo"
io
.close_write
p io.gets # => "foo\n"

サブプロセスを指定する方法は2...
...生成した IO オブジェクトを引数にブ
ロックを実行し、ブロックの実行結果を返します。ブロックの実行後、生成したパイ
プは自動的にクローズされます。

p IO.popen("cat", "r+") {|io|
io
.puts "foo"
io
.close_write
io
.gets
}
#...
...ョンや、パイプ IO オブジェクトの属性(エンコーディングや
読み書き能力)を指定することができます。
プロセス起動のためのオプションは Kernel.#spawn と、
パイプオブジェクトの属性の指定のオプションは IO.new と共通です...

IO.popen(env = {}, [[cmdname, arg0], *args, execopt={}], mode = "r", opt={}) {|f| ... } -> object (13.0)

サブプロセスを実行し、そのプロセスの標準入出力 との間にパイプラインを確立します。生成したパイプを IO オブジェクトとして返します。

...出力
との間にパイプラインを確立します。生成したパイプを IO オブジェクトとして返します。

p io = IO.popen("cat", "r+") # => #<IO:fd 4>
io
.puts "foo"
io
.close_write
p io.gets # => "foo\n"

サブプロセスを指定する方法は2...
...生成した IO オブジェクトを引数にブ
ロックを実行し、ブロックの実行結果を返します。ブロックの実行後、生成したパイ
プは自動的にクローズされます。

p IO.popen("cat", "r+") {|io|
io
.puts "foo"
io
.close_write
io
.gets
}
#...
...ョンや、パイプ IO オブジェクトの属性(エンコーディングや
読み書き能力)を指定することができます。
プロセス起動のためのオプションは Kernel.#spawn と、
パイプオブジェクトの属性の指定のオプションは IO.new と共通です...

絞り込み条件を変える

<< < ... 2 3 4 5 6 ... > >>