検索結果
先頭5件
-
IO
# tell -> Integer (15107.0) -
ファイルポインタの現在の位置を整数で返します。
...タの現在の位置を整数で返します。
@raise IOError 既に close されている場合に発生します。
//emlist[例][ruby]{
IO.write("testfile", "This is line one\n")
File.open("testfile") do |f|
f.pos # => 0
f.gets # => "This is line one\n"
f.pos # => 17
end
//}... -
Zlib
:: GzipWriter # tell -> Integer (15107.0) -
現在までに圧縮したデータの長さの合計を返します。 ファイルポインタの位置ではないことに注意して下さい。
...さの合計を返します。
ファイルポインタの位置ではないことに注意して下さい。
require 'zlib'
filename='hoge1.gz'
f = File.open(filename, "w")
Zlib::GzipWriter.wrap(f, Zlib::BEST_COMPRESSION){|gz|
(1..10).each {|i|
gz.print i
puts gz.pos
}... -
CSV
. open(filename , mode = "rb" , options = Hash . new) -> CSV (148.0) -
このメソッドは IO オブジェクトをオープンして CSV でラップします。 これは CSV ファイルを書くための主要なインターフェイスとして使うことを意図しています。
...ジェクトは多くのメソッドを IO や File に委譲します。
* IO#binmode
* IO#binmode?
* IO#close
* IO#close_read
* IO#close_write
* IO#closed?
* IO#eof
* IO#eof?
* IO#external_encoding
* IO#fcntl
* IO#fileno
* File#flock
* IO#flush
* IO#fsync
* IO#intern......* IO#pos
* IO#pos=
* IO#reopen
* IO#seek
* IO#stat
* StringIO#string
* IO#sync
* IO#sync=
* IO#tell
* IO#to_i
* IO#to_io
* File#truncate
* IO#tty?
@param filename ファイル名を指定します。
@param mode IO.open に指定できるものと同じものを指定で.......new のオプションと同じオプションを指定できます。
//emlist[例 読み取り・ブロック指定なし][ruby]{
require "csv"
File.write("test.csv", <<CSV)
id,first name,last name,age
1,taro,tanaka,20
2,jiro,suzuki,18
3,ami,sato,19
4,yumi,adachi,21
CSV
csv = CSV.open("test.csv... -
CSV
. open(filename , mode = "rb" , options = Hash . new) {|csv| . . . } -> nil (148.0) -
このメソッドは IO オブジェクトをオープンして CSV でラップします。 これは CSV ファイルを書くための主要なインターフェイスとして使うことを意図しています。
...ジェクトは多くのメソッドを IO や File に委譲します。
* IO#binmode
* IO#binmode?
* IO#close
* IO#close_read
* IO#close_write
* IO#closed?
* IO#eof
* IO#eof?
* IO#external_encoding
* IO#fcntl
* IO#fileno
* File#flock
* IO#flush
* IO#fsync
* IO#intern......* IO#pos
* IO#pos=
* IO#reopen
* IO#seek
* IO#stat
* StringIO#string
* IO#sync
* IO#sync=
* IO#tell
* IO#to_i
* IO#to_io
* File#truncate
* IO#tty?
@param filename ファイル名を指定します。
@param mode IO.open に指定できるものと同じものを指定で.......new のオプションと同じオプションを指定できます。
//emlist[例 読み取り・ブロック指定なし][ruby]{
require "csv"
File.write("test.csv", <<CSV)
id,first name,last name,age
1,taro,tanaka,20
2,jiro,suzuki,18
3,ami,sato,19
4,yumi,adachi,21
CSV
csv = CSV.open("test.csv... -
CSV
. open(filename , options = Hash . new) -> CSV (148.0) -
このメソッドは IO オブジェクトをオープンして CSV でラップします。 これは CSV ファイルを書くための主要なインターフェイスとして使うことを意図しています。
...ジェクトは多くのメソッドを IO や File に委譲します。
* IO#binmode
* IO#binmode?
* IO#close
* IO#close_read
* IO#close_write
* IO#closed?
* IO#eof
* IO#eof?
* IO#external_encoding
* IO#fcntl
* IO#fileno
* File#flock
* IO#flush
* IO#fsync
* IO#intern......* IO#pos
* IO#pos=
* IO#reopen
* IO#seek
* IO#stat
* StringIO#string
* IO#sync
* IO#sync=
* IO#tell
* IO#to_i
* IO#to_io
* File#truncate
* IO#tty?
@param filename ファイル名を指定します。
@param mode IO.open に指定できるものと同じものを指定で.......new のオプションと同じオプションを指定できます。
//emlist[例 読み取り・ブロック指定なし][ruby]{
require "csv"
File.write("test.csv", <<CSV)
id,first name,last name,age
1,taro,tanaka,20
2,jiro,suzuki,18
3,ami,sato,19
4,yumi,adachi,21
CSV
csv = CSV.open("test.csv... -
CSV
. open(filename , options = Hash . new) {|csv| . . . } -> nil (148.0) -
このメソッドは IO オブジェクトをオープンして CSV でラップします。 これは CSV ファイルを書くための主要なインターフェイスとして使うことを意図しています。
...ジェクトは多くのメソッドを IO や File に委譲します。
* IO#binmode
* IO#binmode?
* IO#close
* IO#close_read
* IO#close_write
* IO#closed?
* IO#eof
* IO#eof?
* IO#external_encoding
* IO#fcntl
* IO#fileno
* File#flock
* IO#flush
* IO#fsync
* IO#intern......* IO#pos
* IO#pos=
* IO#reopen
* IO#seek
* IO#stat
* StringIO#string
* IO#sync
* IO#sync=
* IO#tell
* IO#to_i
* IO#to_io
* File#truncate
* IO#tty?
@param filename ファイル名を指定します。
@param mode IO.open に指定できるものと同じものを指定で.......new のオプションと同じオプションを指定できます。
//emlist[例 読み取り・ブロック指定なし][ruby]{
require "csv"
File.write("test.csv", <<CSV)
id,first name,last name,age
1,taro,tanaka,20
2,jiro,suzuki,18
3,ami,sato,19
4,yumi,adachi,21
CSV
csv = CSV.open("test.csv... -
Kernel
$ $ stdin -> object (12.0) -
標準入力です。
...イレクトしたいときは
$stdin に代入すれば十分です。
//emlist[例][ruby]{
# 標準入力の入力元 /tmp/foo に変更
$stdin = File.open("/tmp/foo", "r")
gets # 入力する
$stdin = STDIN # 元に戻す
//}
ただし、Kernel.#gets など、特定の組み......トが以下のメソッドを
正しく実装していなければいけません。
gets, readline, readlines, getc, readchar, tell, seek,
pos=, rewind, fileno, to_io, eof, each_line, each_byte,
binmode, closed?
//emlist[例][ruby]{
$stdin = Object.new
def $stdin.gets
"foo"
end
p g... -
IO
# pos -> Integer (7.0) -
ファイルポインタの現在の位置を整数で返します。
...タの現在の位置を整数で返します。
@raise IOError 既に close されている場合に発生します。
//emlist[例][ruby]{
IO.write("testfile", "This is line one\n")
File.open("testfile") do |f|
f.pos # => 0
f.gets # => "This is line one\n"
f.pos # => 17
end
//}... -
Zlib
:: GzipWriter # pos -> Integer (7.0) -
現在までに圧縮したデータの長さの合計を返します。 ファイルポインタの位置ではないことに注意して下さい。
...さの合計を返します。
ファイルポインタの位置ではないことに注意して下さい。
require 'zlib'
filename='hoge1.gz'
f = File.open(filename, "w")
Zlib::GzipWriter.wrap(f, Zlib::BEST_COMPRESSION){|gz|
(1..10).each {|i|
gz.print i
puts gz.pos
}...