ライブラリ
- ビルトイン (446)
- csv (36)
- erb (36)
-
irb
/ input-method (48) -
net
/ http (48) - pathname (12)
-
rubygems
/ package / tar _ reader / entry (12) -
rubygems
/ source _ info _ cache (12) - shell (18)
-
shell
/ command-processor (18) -
shell
/ filter (18) - zlib (108)
クラス
-
ARGF
. class (60) - CSV (36)
- Dir (12)
- ERB (36)
- File (12)
-
File
:: Stat (48) -
Gem
:: Package :: TarReader :: Entry (12) -
Gem
:: SourceInfoCache (12) - IO (274)
-
IRB
:: InputMethod (12) -
IRB
:: ReadlineInputMethod (24) -
IRB
:: StdioInputMethod (12) - Method (14)
-
Net
:: HTTPGenericRequest (24) -
Net
:: HTTPResponse (24) - Pathname (12)
- Proc (14)
- Shell (18)
-
Shell
:: CommandProcessor (18) -
Shell
:: Filter (18) - String (12)
-
Zlib
:: GzipReader (24) -
Zlib
:: GzipWriter (84)
キーワード
- << (38)
- >> (14)
-
add
_ row (12) - birthtime (12)
-
body
_ stream (12) -
body
_ stream= (12) - clone (12)
- close (12)
- closed? (12)
- count (12)
-
def
_ class (12) - dup (12)
- eof? (12)
- fdatasync (12)
- file? (12)
- filename (24)
- filename= (12)
- flock (12)
- flush (24)
- getc (12)
- path (12)
- pread (8)
- print (12)
- printf (12)
- putc (12)
- puts (24)
- pwrite (8)
-
read
_ body (24) -
read
_ cache _ data (12) - readable? (30)
-
readable
_ atfer _ eof? (36) -
readable
_ real? (30) - readbyte (24)
- readchar (36)
- readline (48)
- readlines (36)
- readlink (30)
-
set
_ encoding _ by _ bom (6) - sysread (12)
- sysseek (12)
- syswrite (12)
- ungetc (12)
-
world
_ readable? (12) - write (24)
検索結果
先頭5件
-
Net
:: HTTPResponse # read _ body(dest=nil) -> String|nil (6139.0) -
ブロックを与えなかった場合にはエンティティボディを 文字列で返します。 ブロックを与えた場合には エンティティボディを少しずつ取得して順次ブロックに 文字列で与えます。
...ri))
response.read_body[0..10] # => "<!doctype h"
//}
//emlist[例2 ブロックを与えて大きいファイルを取得][ruby]{
require 'net/http'
uri = URI.parse('http://www.example.com/path/to/big.file')
Net::HTTP.start(uri.host, uri.port) do |http|
File.open("/path/to/big.file", "w") do |f......|
# Net::HTTP#request_get と Net::HTTPResponse#read_body で少しずつ読み書き。メモリ消費が少ない。
http.request_get(uri.path) do |response|
response.read_body do |s|
f.write(s)
end
end
end
end
//}
一度ブロックを与えずにこのメソッ......ボディを文字列として
返します。また一度ブロックを与えてこのメソッドを呼んだ場合には、
次からは Net::ReadAdapter のインスタンスが返ってきますが、
その場合はそのオブジェクトは使わないでください。
dest は obsolete... -
IO
# readlines(limit , chomp: false) -> [String] (6131.0) -
データを全て読み込んで、その各行を要素としてもつ配列を返します。 既に EOF に達していれば空配列 [] を返します。
....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(",")......t[例: rsを取り除く(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"... -
IO
# readlines(rs = $ / , chomp: false) -> [String] (6131.0) -
データを全て読み込んで、その各行を要素としてもつ配列を返します。 既に EOF に達していれば空配列 [] を返します。
....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(",")......t[例: rsを取り除く(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"... -
IO
# readlines(rs , limit , chomp: false) -> [String] (6131.0) -
データを全て読み込んで、その各行を要素としてもつ配列を返します。 既に EOF に達していれば空配列 [] を返します。
....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(",")......t[例: rsを取り除く(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"... -
IO
# pread(maxlen , offset , outbuf = "") -> string (6125.0) -
preadシステムコールを使ってファイルポインタを変更せずに、また現在のファイルポインタに 依存せずにmaxlenバイト読み込みます。
...preadシステムコールを使ってファイルポインタを変更せずに、また現在のファイルポインタに
依存せずにmaxlenバイト読み込みます。
IO#seekとIO#readの組み合わせと比べて、アトミックな操作に
なるという点が優れていて、複......ない OS で発生します。
//emlist[例][ruby]{
File.write("testfile", "This is line one\nThis is line two\n")
File.open("testfile") do |f|
p f.read # => "This is line one\nThis is line two\n"
p f.pread(12, 0) # => "This is line"
p f.pread(9, 8) # => "line one\n"
end
//}... -
IO
# sysread(maxlen , outbuf = "") -> String (6123.0) -
read(2) を用いて入力を行ない、入力されたデータを 含む文字列を返します。stdio を経由しないので gets や getc や eof? などと混用すると思わぬ動作 をすることがあります。
...
read(2) を用いて入力を行ない、入力されたデータを
含む文字列を返します。stdio を経由しないので gets や getc や eof? などと混用すると思わぬ動作
をすることがあります。
バイナリ読み込みメソッドとして動作します。
既......。
@param maxlen 入力のサイズを整数で指定します。
@param outbuf 出力用のバッファを文字列で指定します。IO#sysread は読み込んだデータを
その文字列オブジェクトに上書きして返します。指定した文字列オブジェク......す。
第二引数を指定した sysread の呼び出しでデータが空であった場
合(sysread が例外 EOFError を発生させる場合)、
outbuf は空文字列になります。
outbuf = "x" * 20;
io = File.open("/dev/null")
p((io.sysread(10,outbuf) rescue nil))
p outbuf
=... -
Pathname
# readlink -> Pathname (6123.0) -
Pathname.new(File.readlink(self.to_s)) と同じです。
...Pathname.new(File.readlink(self.to_s)) と同じです。
@see File.readlink... -
Shell
# readlink(path) -> String (6123.0) -
File クラスにある同名のクラスメソッドと同じです.
...File クラスにある同名のクラスメソッドと同じです.
@param path シンボリックリンクを表す文字列を指定します。
@see File.readlink... -
Shell
:: CommandProcessor # readlink(path) -> String (6123.0) -
File クラスにある同名のクラスメソッドと同じです.
...File クラスにある同名のクラスメソッドと同じです.
@param path シンボリックリンクを表す文字列を指定します。
@see File.readlink... -
Shell
:: Filter # readlink(path) -> String (6123.0) -
File クラスにある同名のクラスメソッドと同じです.
...File クラスにある同名のクラスメソッドと同じです.
@param path シンボリックリンクを表す文字列を指定します。
@see File.readlink... -
ARGF
. class # readbyte -> Integer (6119.0) -
自身から 1 バイトを読み込み整数として返します。 既に EOF に達していれば EOFError が発生します。
...が発生します。
@raise EOFError 既に EOF に達している場合に発生します。
$ echo "foo" > file
$ ruby argf.rb file
ARGF.readbyte # => 102
ARGF.readbyte # => 111
ARGF.readbyte # => 111
ARGF.readbyte # => 10
ARGF.readbyte # => end of file reached (EOFError)... -
ARGF
. class # readchar -> String (6119.0) -
ARGFから 1 文字読み込んで、その文字に対応する String を返します。EOF に 到達した時には EOFErrorを発生します。
...rorを発生します。
@raise EOFError EOFに達した時発生する
$ echo "foo" > file
$ ruby argf.rb file
ARGF.readchar # => "f"
ARGF.readchar # => "o"
ARGF.readchar # => "o"
ARGF.readchar # => "\n"
ARGF.readchar # => end of file reached (EOFError)
@see ARGF.class#getc...