種類
- インスタンスメソッド (66)
- 特異メソッド (44)
- 変数 (11)
クラス
- CSV (44)
- Dir (22)
- IO (22)
-
Zlib
:: GzipReader (22)
モジュール
- Kernel (11)
検索結果
先頭5件
-
IO
# tell -> Integer (18207.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
:: GzipReader # tell -> Integer (18207.0) -
現在までに展開したデータの長さの合計を返します。 ファイルポインタの位置ではないことに注意して下さい。
...位置ではないことに注意して下さい。
require 'zlib'
Zlib::GzipWriter.open('hoge.gz') { |gz|
gz.puts 'hoge'
}
Zlib::GzipReader.open('hoge.gz'){|gz|
while c = gz.getc
printf "%c, %d\n", c, gz.pos
end
}
# 実行例
#=> h, 1
#=> o, 2
#=> g, 3
#=> e... -
Kernel
$ $ stdin -> object (6112.0) -
標準入力です。
...$stdin に代入すれば十分です。
//emlist[例][ruby]{
# 標準入力の入力元 /tmp/foo に変更
$stdin = File.open("/tmp/foo", "r")
gets # 入力する
$stdin = STDIN # 元に戻す
//}
ただし、Kernel.#gets など、特定の組み込みメソッドは
$stdin オ......、
$stdin オブジェクトに代入したオブジェクトが以下のメソッドを
正しく実装していなければいけません。
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 gets() # => "foo"
//}
自プロセスだけでなく、子プロセスの標準入力もリダイレクトしたいときは
以下のように IO#reopen を使います。
//emlist[例][ruby]{
$stdin.reopen("/tmp/foo")
//}
また、リ... -
IO
# pos -> Integer (3107.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
:: GzipReader # pos -> Integer (3107.0) -
現在までに展開したデータの長さの合計を返します。 ファイルポインタの位置ではないことに注意して下さい。
...位置ではないことに注意して下さい。
require 'zlib'
Zlib::GzipWriter.open('hoge.gz') { |gz|
gz.puts 'hoge'
}
Zlib::GzipReader.open('hoge.gz'){|gz|
while c = gz.getc
printf "%c, %d\n", c, gz.pos
end
}
# 実行例
#=> h, 1
#=> o, 2
#=> g, 3
#=> e... -
Dir
# pos=(pos) (3040.0) -
ディレクトリストリームの読み込み位置を pos に移動させます。 pos は Dir#tell で与えられた値でなければなりま せん。
...ir#tell で与えられた値でなければなりま
せん。
@param pos 変更したい位置を整数で与えます。
@raise IOError 既に自身が close している場合に発生します。
//emlist[例][ruby]{
Dir.open("testdir") do |d|
d.read # => "."
i = d.tell......# => 12
d.read # => ".."
d.seek(i) # => #<Dir:0x401b3c40>
d.read # => ".."
end
//}... -
Dir
# seek(pos) -> self (3040.0) -
ディレクトリストリームの読み込み位置を pos に移動させます。 pos は Dir#tell で与えられた値でなければなりま せん。
...ir#tell で与えられた値でなければなりま
せん。
@param pos 変更したい位置を整数で与えます。
@raise IOError 既に自身が close している場合に発生します。
//emlist[例][ruby]{
Dir.open("testdir") do |d|
d.read # => "."
i = d.tell......# => 12
d.read # => ".."
d.seek(i) # => #<Dir:0x401b3c40>
d.read # => ".."
end
//}... -
CSV
. open(filename , mode = "rb" , options = Hash . new) {|csv| . . . } -> nil (224.0) -
このメソッドは IO オブジェクトをオープンして CSV でラップします。 これは CSV ファイルを書くための主要なインターフェイスとして使うことを意図しています。
...このメソッドは IO オブジェクトをオープンして CSV でラップします。
これは CSV ファイルを書くための主要なインターフェイスとして使うことを意図しています。
このメソッドは IO.open と同じように動きます。ブロックが......* IO#eof?
* IO#external_encoding
* IO#fcntl
* IO#fileno
* File#flock
* IO#flush
* IO#fsync
* IO#internal_encoding
* IO#ioctl
* IO#isatty
* File#path
* IO#pid
* IO#pos
* IO#pos=
* IO#reopen
* IO#seek
* IO#stat
* StringIO#string
* IO#sync
* IO#sync=
* IO#tell......
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", users)
CSV.open("test.csv", headers: true) do |csv|
csv.class # => CSV
csv.first # => #<CSV::Row "id":"1" "first name":"taro" "last name":"tanaka" "age":"20">
end
//}
//emli... -
CSV
. open(filename , options = Hash . new) {|csv| . . . } -> nil (224.0) -
このメソッドは IO オブジェクトをオープンして CSV でラップします。 これは CSV ファイルを書くための主要なインターフェイスとして使うことを意図しています。
...このメソッドは IO オブジェクトをオープンして CSV でラップします。
これは CSV ファイルを書くための主要なインターフェイスとして使うことを意図しています。
このメソッドは IO.open と同じように動きます。ブロックが......* IO#eof?
* IO#external_encoding
* IO#fcntl
* IO#fileno
* File#flock
* IO#flush
* IO#fsync
* IO#internal_encoding
* IO#ioctl
* IO#isatty
* File#path
* IO#pid
* IO#pos
* IO#pos=
* IO#reopen
* IO#seek
* IO#stat
* StringIO#string
* IO#sync
* IO#sync=
* IO#tell......
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", users)
CSV.open("test.csv", headers: true) do |csv|
csv.class # => CSV
csv.first # => #<CSV::Row "id":"1" "first name":"taro" "last name":"tanaka" "age":"20">
end
//}
//emli... -
CSV
. open(filename , mode = "rb" , options = Hash . new) -> CSV (124.0) -
このメソッドは IO オブジェクトをオープンして CSV でラップします。 これは CSV ファイルを書くための主要なインターフェイスとして使うことを意図しています。
...このメソッドは IO オブジェクトをオープンして CSV でラップします。
これは CSV ファイルを書くための主要なインターフェイスとして使うことを意図しています。
このメソッドは IO.open と同じように動きます。ブロックが......* IO#eof?
* IO#external_encoding
* IO#fcntl
* IO#fileno
* File#flock
* IO#flush
* IO#fsync
* IO#internal_encoding
* IO#ioctl
* IO#isatty
* File#path
* IO#pid
* IO#pos
* IO#pos=
* IO#reopen
* IO#seek
* IO#stat
* StringIO#string
* IO#sync
* IO#sync=
* IO#tell......
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", users)
CSV.open("test.csv", headers: true) do |csv|
csv.class # => CSV
csv.first # => #<CSV::Row "id":"1" "first name":"taro" "last name":"tanaka" "age":"20">
end
//}
//emli...