ライブラリ
クラス
- Array (4)
- BasicSocket (12)
-
CSV
:: Table (24) - IO (88)
- Module (12)
-
Net
:: HTTPResponse (24) -
Net
:: Telnet (6) -
OpenSSL
:: SSL :: SSLSocket (12) - Pathname (24)
-
REXML
:: Entity (12) -
Rake
:: FileList (24) - Socket (12)
- StringIO (96)
-
Zlib
:: GzipWriter (12)
検索結果
先頭5件
-
IO
# readlines(rs = $ / , chomp: false) -> [String] (116.0) -
データを全て読み込んで、その各行を要素としてもつ配列を返します。 既に EOF に達していれば空配列 [] を返します。
...を取り除きます。
@raise IOError 自身が読み込み用にオープンされていなければ発生します。
//emlist[例][ruby]{
IO.write("testfile", "line1,\nline2,\nline3,\n")
File.open("testfile") { |f| p f.readlines } # => ["line1,\n", "line2,\n", "line3,\n"]
File.open("test......stfile") { |f| p f.readlines(",") } # => ["line1,", "\nline2,", "\nline3,", "\n"]
//}
//emlist[例: 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.op... -
IO
# readlines(rs , limit , chomp: false) -> [String] (116.0) -
データを全て読み込んで、その各行を要素としてもつ配列を返します。 既に EOF に達していれば空配列 [] を返します。
...を取り除きます。
@raise IOError 自身が読み込み用にオープンされていなければ発生します。
//emlist[例][ruby]{
IO.write("testfile", "line1,\nline2,\nline3,\n")
File.open("testfile") { |f| p f.readlines } # => ["line1,\n", "line2,\n", "line3,\n"]
File.open("test......stfile") { |f| p f.readlines(",") } # => ["line1,", "\nline2,", "\nline3,", "\n"]
//}
//emlist[例: 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.op... -
CSV
:: Table # to _ csv(options = Hash . new) -> String (115.0) -
CSV の文字列に変換して返します。
...す。オプションに :write_headers =>
false を指定するとヘッダを出力しません。
//emlist[][ruby]{
require 'csv'
csv = CSV.new("a,b,c\n1,2,3", headers: true)
table = csv.read
p table.to_csv # => "a,b,c\n1,2,3\n"
p table.to_csv(write_headers: false) # => "1,... -
CSV
:: Table # to _ s(options = Hash . new) -> String (115.0) -
CSV の文字列に変換して返します。
...す。オプションに :write_headers =>
false を指定するとヘッダを出力しません。
//emlist[][ruby]{
require 'csv'
csv = CSV.new("a,b,c\n1,2,3", headers: true)
table = csv.read
p table.to_csv # => "a,b,c\n1,2,3\n"
p table.to_csv(write_headers: false) # => "1,... -
Array
# to _ csv(**options) -> String (114.0) -
CSV.generate_line(self, options) と同様です。
.../emlist[][ruby]{
require 'csv'
puts [1, nil].to_csv # => 1,
puts [1, nil].to_csv(write_nil_value: "N/A") # => 1,N/A
puts [2, ""].to_csv # => 2,""
puts [2, ""].to_csv(write_empty_value: "BLANK") # => 2,BLANK
//}
@see CSV.generate_line... -
IO
# pread(maxlen , offset , outbuf = "") -> string (114.0) -
preadシステムコールを使ってファイルポインタを変更せずに、また現在のファイルポインタに 依存せずにmaxlenバイト読み込みます。
...@param offset 読み込み開始位置のファイルの先頭からのオフセットを指定します。
@param outbuf データを受け取る String を指定します。
@raise Errno::EXXX シークまたは書き込みが失敗した場合に発生します。
@raise EOFError EOF に到達......します。
@raise NotImplementedError システムコールがサポートされていない 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"... -
Net
:: Telnet # print(string) -> () (114.0) -
ホストに文字列を送ります。
...プされます。
これらの変換はNet::Telnet#telnetmode, Net::Telnet#binmode,
およびホストから設定された telnet オプションによって(変換するしないなどが)
制御されます。
@param string ホストに送る文字列
@see Net::Telnet#write, Net::Telnet#puts... -
Net
:: Telnet # puts(string) -> () (114.0) -
改行を付加した文字列をホストに送ります。
...改行を付加した文字列をホストに送ります。
改行の付加以外は Net::Telnet#print と同じです。
@param string ホストに送る文字列
@see Net::Telnet#write, Net::Telnet#print... -
IO
# readlines(limit) -> [String] (110.0) -
データを全て読み込んで、その各行を要素としてもつ配列を返します。 既に EOF に達していれば空配列 [] を返します。
...読み込みバイト数
@raise IOError 自身が読み込み用にオープンされていなければ発生します。
//emlist[例][ruby]{
IO.write("testfile", "line1,\nline2,\nline3,\n")
File.open("testfile") { |f| p f.readlines } # => ["line1,\n", "line2,\n", "line3,\n"]
File.open("test... -
IO
# readlines(rs = $ / ) -> [String] (110.0) -
データを全て読み込んで、その各行を要素としてもつ配列を返します。 既に EOF に達していれば空配列 [] を返します。
...読み込みバイト数
@raise IOError 自身が読み込み用にオープンされていなければ発生します。
//emlist[例][ruby]{
IO.write("testfile", "line1,\nline2,\nline3,\n")
File.open("testfile") { |f| p f.readlines } # => ["line1,\n", "line2,\n", "line3,\n"]
File.open("test... -
IO
# readlines(rs , limit) -> [String] (110.0) -
データを全て読み込んで、その各行を要素としてもつ配列を返します。 既に EOF に達していれば空配列 [] を返します。
...読み込みバイト数
@raise IOError 自身が読み込み用にオープンされていなければ発生します。
//emlist[例][ruby]{
IO.write("testfile", "line1,\nline2,\nline3,\n")
File.open("testfile") { |f| p f.readlines } # => ["line1,\n", "line2,\n", "line3,\n"]
File.open("test... -
BasicSocket
# recv(maxlen , flags = 0) -> String (108.0) -
ソケットからデータを受け取り、文字列として返します。 maxlen は受け取る最大の長さを指定します。 flags については recv(2) を参照してください。flags の デフォルト値は 0 です。flags の指定に必要な定数は Socket クラスで定義されています。(例: Socket::MSG_PEEK)
...@raise Errno::EXXX recvfrom(2) がエラーになった場合などに発生します。
例:
require 'socket'
s1, s2 = UNIXSocket.pair
s1.write "a"
s1.close
p s2.recv(10, Socket::MSG_PEEK) #=> "a"
p s2.recv(10) #=> "a"
p s2.recv(10) #=> ""... -
IO
# getc -> String | nil (108.0) -
IO ポートから外部エンコーディングに従い 1 文字読み込んで返します。 EOF に到達した時には nil を返します。
...F での振る舞いのみです。
@raise IOError 自身が読み込み用にオープンされていなければ発生します。
例:
File.write("testfile", "test")
f = File.new("testfile")
p f.getc #=> "い"
p f.getc #=> "ろ"
p f.getc... -
Net
:: HTTPResponse # read _ body(dest=nil) -> String|nil (108.0) -
ブロックを与えなかった場合にはエンティティボディを 文字列で返します。 ブロックを与えた場合には エンティティボディを少しずつ取得して順次ブロックに 文字列で与えます。
...で少しずつ読み書き。メモリ消費が少ない。
http.request_get(uri.path) do |response|
response.read_body do |s|
f.write(s)
end
end
end
end
//}
一度ブロックを与えずにこのメソッドを呼んだ場合には、
次からはすでに読みだ...