別のキーワード
ライブラリ
クラス
-
ARGF
. class (84) - Addrinfo (24)
- CSV (312)
-
CSV
:: Table (84) - Dir (120)
- ERB (36)
-
Encoding
:: Converter (12) - Exception (12)
- File (84)
-
File
:: Stat (48) - IO (298)
-
IRB
:: Context (24) -
JSON
:: Parser (36) - Method (14)
- Module (12)
-
Net
:: HTTP (96) -
Net
:: HTTPGenericRequest (24) -
Net
:: HTTPResponse (48) - Object (30)
- Pathname (12)
- Proc (14)
- Socket (36)
- String (12)
- StringIO (84)
- Thread (307)
-
Thread
:: Backtrace :: Location (84) -
Thread
:: ConditionVariable (24) -
Thread
:: Mutex (50) -
Thread
:: Queue (114) -
Thread
:: SizedQueue (70) - ThreadGroup (36)
キーワード
-
$ INPUT _ LINE _ NUMBER (12) -
$ LAST _ READ _ LINE (12) -
$ NR (12) -
1
. 6 . 8から1 . 8 . 0への変更点(まとめ) (12) - << (26)
- >> (14)
- CSV (12)
- ConditionVariable (12)
- DEBUG (12)
- DEBUG= (12)
- Location (12)
-
NEWS for Ruby 2
. 1 . 0 (12) -
NEWS for Ruby 2
. 2 . 0 (11) -
NEWS for Ruby 2
. 3 . 0 (10) -
NEWS for Ruby 2
. 5 . 0 (8) -
NEWS for Ruby 2
. 6 . 0 (7) -
NEWS for Ruby 3
. 0 . 0 (5) -
NEWS for Ruby 3
. 1 . 0 (4) - Pathname (12)
- Queue (12)
- SizedQueue (12)
- StringIO (12)
- Thread (12)
- [] (12)
-
abort
_ on _ exception (24) -
abort
_ on _ exception= (24) -
absolute
_ path (12) - add (12)
-
add
_ row (12) -
add
_ trace _ func (12) -
attr
_ reader (12) - backtrace (12)
-
backtrace
_ locations (36) -
base
_ label (12) - binmode (12)
- binread (24)
- birthtime (12)
- body (12)
-
body
_ stream (12) -
body
_ stream= (12) - broadcast (12)
-
caller
_ locations (24) - cgi (12)
- clear (12)
- clone (12)
- close (22)
-
close
_ read (12) -
close
_ write (12) - closed? (34)
- connect (12)
-
connect
_ from (24) - convert (36)
-
copy
_ stream (24) - count (12)
- decode (12)
-
def
_ class (12) - deq (24)
- dup (12)
- empty? (24)
- entity (12)
- fdatasync (12)
- fetch (8)
-
field
_ size _ limit (12) - file (12)
- filename (24)
- filename= (12)
- flock (12)
- flush (12)
- get2 (24)
- gets (12)
-
header
_ converters (12) - headers (12)
-
ignore
_ deadlock= (4) - inspect (36)
- instance (24)
- key? (12)
- label (12)
- length (24)
- lineno (12)
- link (12)
- list (12)
- load (12)
- locked? (10)
- max (12)
- max= (12)
- name= (10)
- new (80)
-
num
_ waiting (12) - open (124)
- open-uri (12)
- owned? (10)
- parse (12)
- path (24)
- pop (24)
- pos= (12)
- post2 (24)
- pread (8)
-
primitive
_ errinfo (12) - priority (12)
- priority= (12)
- push (12)
- puts (12)
- pwrite (8)
-
rb
_ thread _ select (1) -
rb
_ thread _ start _ timer (12) -
rb
_ thread _ stop _ timer (12) -
rdoc
/ parser / c (12) -
read
_ body (24) - readable? (24)
-
readable
_ real? (12) - readbyte (36)
- readchar (24)
- readline (48)
- readlines (120)
- readlink (12)
- reopen (24)
-
report
_ on _ exception (9) -
report
_ on _ exception= (9) -
request
_ get (24) -
request
_ post (24) - restore (12)
- rewind (12)
-
rinda
/ rinda (12) -
row
_ sep (12) - rss (12)
-
ruby 1
. 6 feature (12) -
ruby 1
. 8 . 2 feature (12) -
ruby 1
. 8 . 3 feature (12) -
ruby 1
. 8 . 4 feature (12) -
ruby 1
. 8 . 5 feature (12) -
ruby 1
. 9 feature (12) -
rubygems
/ package / tar _ reader (12) -
rubygems
/ package / tar _ reader / entry (12) - run (12)
-
safe
_ level (7) - seek (12)
-
set
_ encoding _ by _ bom (6) -
set
_ trace _ func (12) - shift (36)
- signal (12)
- size (24)
-
skip
_ blanks? (12) - sleep (10)
- source (12)
- spawn (48)
- stop (12)
- stop? (12)
- synchronize (10)
- syswrite (12)
- table (12)
- tcp (24)
- then (14)
- thread (2)
-
thread
_ variable _ set (12) - timeout (21)
-
to
_ csv (12) -
to
_ s (32) -
try
_ lock (10) -
use
_ readline (12) -
use
_ readline? (12) -
wait
_ readable (12) - wakeup (12)
-
world
_ readable? (24) - write (36)
-
yield
_ self (16) - スレッド (12)
検索結果
先頭5件
-
CSV
# readlines -> [Array] | CSV :: Table (6137.0) -
残りの行を読み込んで配列の配列を返します。 self の生成時に headers オプションに偽でない値が指定されていた場合は CSV::Table オブジェクトを返します。
...false][ruby]{
require "csv"
csv = CSV.new(DATA.read)
csv.read
# => [["header1", "header2"], ["row1_1", "row1_2"], ["row2_1", "row2_2"]]
__END__
header1,header2
row1_1,row1_2
row2_1,row2_2
//}
//emlist[例 headers: true][ruby]{
require "csv"
csv = CSV.new(DATA.read, headers: true)
csv.read
# => #... -
Net
:: HTTPResponse # read _ body {|str| . . . . } -> () (6132.0) -
ブロックを与えなかった場合にはエンティティボディを 文字列で返します。 ブロックを与えた場合には エンティティボディを少しずつ取得して順次ブロックに 文字列で与えます。
...ずに一度に結果取得][ruby]{
require 'net/http'
uri = "http://www.example.com/index.html"
response = Net::HTTP.get_response(URI.parse(uri))
response.read_body[0..10] # => "<!doctype h"
//}
//emlist[例2 ブロックを与えて大きいファイルを取得][ruby]{
require 'net/http'
uri =......"/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... -
Net
:: HTTPResponse # read _ body(dest=nil) -> String|nil (6132.0) -
ブロックを与えなかった場合にはエンティティボディを 文字列で返します。 ブロックを与えた場合には エンティティボディを少しずつ取得して順次ブロックに 文字列で与えます。
...ずに一度に結果取得][ruby]{
require 'net/http'
uri = "http://www.example.com/index.html"
response = Net::HTTP.get_response(URI.parse(uri))
response.read_body[0..10] # => "<!doctype h"
//}
//emlist[例2 ブロックを与えて大きいファイルを取得][ruby]{
require 'net/http'
uri =......"/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... -
CSV
. readlines(path , options = Hash . new) -> [Array] | CSV :: Table (6125.0) -
CSV ファイルを配列の配列にするために使います。 headers オプションに偽でない値を指定した場合は CSV::Table オブジェクトを返します。
...必ず指定しなければなりません。
//emlist[例][ruby]{
require "csv"
require "pp"
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
pp CSV.read("test.csv")
# => [["id", "first name", "last name", "age"],
#......to", "19"],
# ["4", "yumi", "adachi", "21"]]
//}
//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
table = CSV.read("test.csv", headers: true)
p table.class # => CSV::Table
p table[0... -
IO
# pread(maxlen , offset , outbuf = "") -> string (6118.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
# close _ read -> nil (6113.0) -
読み込み用の IO を close します。主にパイプや読み書き両用に作成し た IO オブジェクトで使用します。
...オープンされていなければ発生します。
@raise Errno::EXXX close に失敗した場合に発生します。
//emlist[例][ruby]{
IO.popen("/bin/sh","r+") do |f|
f.close_read
# f.readlines # => IOError: not opened for reading
end
//}
@see IO#close, IO#closed?, IO#close_write... -
Kernel
$ $ LAST _ READ _ LINE -> String | nil (6113.0) -
$_ の別名
...$_ の別名
1 e
2 f
3 g
4 h
5 i
# end of a.txt
ruby -rEnglish -ne'p $LAST_READ_LINE' a.txt
#=>
"1 e\n"
"2 f\n"
"3 g\n"
"4 h\n"
"5 i\n"... -
IO
# readlines(limit , chomp: false) -> [String] (6112.0) -
データを全て読み込んで、その各行を要素としてもつ配列を返します。 既に EOF に達していれば空配列 [] を返します。
...[ruby]{
IO.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.readl....../}
//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.open("testfile") { |f| p f.readlines("\r", chomp: true) } # => ["line1,", "line2,", "... -
IO
# readlines(rs = $ / , chomp: false) -> [String] (6112.0) -
データを全て読み込んで、その各行を要素としてもつ配列を返します。 既に EOF に達していれば空配列 [] を返します。
...[ruby]{
IO.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.readl....../}
//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.open("testfile") { |f| p f.readlines("\r", chomp: true) } # => ["line1,", "line2,", "... -
IO
# readlines(rs , limit , chomp: false) -> [String] (6112.0) -
データを全て読み込んで、その各行を要素としてもつ配列を返します。 既に EOF に達していれば空配列 [] を返します。
...[ruby]{
IO.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.readl....../}
//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.open("testfile") { |f| p f.readlines("\r", chomp: true) } # => ["line1,", "line2,", "...