種類
- 文書 (34)
- インスタンスメソッド (33)
- 変数 (33)
- 定数 (11)
モジュール
- Kernel (33)
キーワード
-
$ INPUT _ RECORD _ SEPARATOR (11) -
$ LAST _ PAREN _ MATCH (11) -
$ RS (11) - DATA (11)
-
NEWS for Ruby 2
. 0 . 0 (11) -
NEWS for Ruby 2
. 4 . 0 (8) -
NEWS for Ruby 3
. 0 . 0 (4) - readline (11)
- shift (11)
- 制御構造 (11)
検索結果
先頭5件
-
CSV
# gets -> Array | CSV :: Row (18107.0) -
String や IO をラップしたデータソースから一行だけ読み込んで フィールドの配列か CSV::Row のインスタンスを返します。
...しない場合は配列を返します。
ヘッダを使用する場合は CSV::Row を返します。
//emlist[例][ruby]{
require "csv"
csv = CSV.new(DATA.read)
csv.readline # => ["header1", "header2"]
csv.readline # => ["row1_1", "row1_2"]
__END__
header1,header2
row1_1,row1_2
//}... -
Object
:: DATA -> File (6251.0) -
スクリプトの __END__ プログラムの終り以降をアクセスする File オブジェクト。
...んでおくことができます。
DATA 定数はそのデータ部分にアクセスするための File オブジェクトを保持しています。
__END__ を含まないプログラムにおいては DATA は定義されません。
=== 注意
* DATA.rewind で移動する読みとり......ァイル ($0) を指します。
=== 例1
print DATA.gets # => 故人西辞黄鶴楼
print DATA.gets # => 烟花三月下揚州
print DATA.gets # => 孤帆遠影碧空尽
print DATA.gets # => 唯見長江天際流
DATA.gets # => nil
__END__
故人西辞黄鶴......江天際流
=== 例2
sum = 0
DATA.each_line do |line|
sum += line.to_i
end
DATA.rewind
p DATA.gets # => "sum = 0¥n"
__END__
17
19
23
29
31
=== 例3
DATA.gets # => uninitialized constant DATA (NameError)
=== 例4
ファイル... -
CSV
# readline -> Array | CSV :: Row (3007.0) -
String や IO をラップしたデータソースから一行だけ読み込んで フィールドの配列か CSV::Row のインスタンスを返します。
...しない場合は配列を返します。
ヘッダを使用する場合は CSV::Row を返します。
//emlist[例][ruby]{
require "csv"
csv = CSV.new(DATA.read)
csv.readline # => ["header1", "header2"]
csv.readline # => ["row1_1", "row1_2"]
__END__
header1,header2
row1_1,row1_2
//}... -
CSV
# shift -> Array | CSV :: Row (3007.0) -
String や IO をラップしたデータソースから一行だけ読み込んで フィールドの配列か CSV::Row のインスタンスを返します。
...しない場合は配列を返します。
ヘッダを使用する場合は CSV::Row を返します。
//emlist[例][ruby]{
require "csv"
csv = CSV.new(DATA.read)
csv.readline # => ["header1", "header2"]
csv.readline # => ["row1_1", "row1_2"]
__END__
header1,header2
row1_1,row1_2
//}... -
NEWS for Ruby 3
. 0 . 0 (54.0) -
NEWS for Ruby 3.0.0 このドキュメントは前回リリース以降のバグ修正を除くユーザーに影響のある機能の変更のリストです。
...*
* Can be sliced with Enumerator::ArithmeticSequence
//emlist[][ruby]{
dirty_data = ['--', 'data1', '--', 'data2', '--', 'data3']
dirty_data[(1..).step(2)] # take each second element
# => ["data1", "data2", "data3"]
//}
* Binding
* Binding#eval when called with one argument will use `"(......IO#nonblock? now defaults to `true`. 16786
* IO#wait_readable, IO#wait_writable, IO#read, IO#write and other related methods (e.g. IO#puts, IO#gets) may invoke the scheduler hook `#io_wait(io, events, timeout)` in a non-blocking execution context. 16786
* Kernel
* Kernel#clone when called......r a bitmap image, between extension libraries. The extension libraries can share also the metadata of the memory area that consists of the shape, the element format, and so on. Using these kinds of metadata, the extension libraries can share even a multidimensional array appropriately. This feature... -
NEWS for Ruby 2
. 0 . 0 (24.0) -
NEWS for Ruby 2.0.0 このドキュメントは前回リリース以降のバグ修正を除くユーザーに影響のある機能の変更のリストです。
...を導入しました。期待しないスタックオーバーフローを避けるためです
* GC::Profiler
* 追加: GC::Profiler.raw_data GCの加工していないプロファイルデータを返します
* Hash
* 追加: Hash#to_h 明示的に変換するメソッドです。A......保持するための低レベルのクラスです。
* Proc
* 非互換: Proc#== と #eql? を削除。
* Process
* 追加: Process#getsid session id を取得します(unix のみ)。
* Range
* 追加: Range#size サイズの遅延評価
* 追加: Range#bsearch 二分探......TLSv1_1 and
OpenSSL::SSL::OP_NO_TLSv1_2.
* Added OpenSSL::SSL::SSLContext#renegotiation_cb. A user-defined callback
may be set which gets called whenever a new handshake is negotiated. This
also allows to programmatically decline (client) renegotiation attempts.
* Support f... -
制御構造 (24.0)
-
制御構造 条件分岐: * if * unless * case 繰り返し: * while * until * for * break * next * redo * retry 例外処理: * raise * begin その他: * return * BEGIN * END
...左辺の式が begin 節である場合にはそれを最初に一回評価してから繰り返します。
//emlist[例][ruby]{
send_request(data)
begin
res = get_response()
end while res == 'Continue'
//}
while 修飾した式は nil を返します。
また、引数を伴った break に......while 修飾した式の戻り値を
その値にすることもできます。
====[a:until] until
//emlist[例][ruby]{
until f.eof?
print f.gets
end
//}
文法:
until 式 [do]
...
end
式を評価した値が真になるまで、本体を繰り返して実......を伴った break により
until 式の戻り値をその値にすることもできます。
==== until修飾子
//emlist[例][ruby]{
print(f.gets) until f.eof?
//}
文法:
式 until 式
右辺の式を評価した値が真になるまで、左辺を繰り返して実行しま
す... -
NEWS for Ruby 2
. 4 . 0 (18.0) -
NEWS for Ruby 2.4.0 このドキュメントは前回リリース以降のバグ修正を除くユーザーに影響のある機能の変更のリストです。
...#gets, IO#readline, IO#each_line, IO#readlines, IO.foreach は
chomp というキーワード引数を受け付けるようになりました。12553
* Kernel
* Kernel#clone は freeze というキーワード引数を受け付けるようになりました。
12300
* MatchData......* MatchData#named_captures を追加 11999
* MatchData#values_at は named captures をサポートするようになりました 9179
* Module
* Module#refine 引数としてモジュールを許可するようになりました 12534
* Module.used_modules を追加 7418
* Nu......* StringIO
* StringIO#gets, StringIO#readline, StringIO#each_line, StringIO#readlines
省略可能なキーワード引数 chomp を受け付けるようになりました 12553
* Symbol
* Symbol#casecmp? を追加 12786
* Symbol#match は MatchData を返すようになりま... -
Kernel
$ $ INPUT _ RECORD _ SEPARATOR -> String | nil (12.0) -
$/ の別名
...$/ の別名
require "English"
$INPUT_RECORD_SEPARATOR = '|'
array = []
while line = DATA.gets
array << line
end
p array #=> ["ugo|", "ego|", "fogo\n"]
__END__
ugo|ego|fogo... -
Kernel
$ $ LAST _ PAREN _ MATCH -> String | nil (12.0) -
$+ の別名
...名
require "English"
r1 = Regexp.compile("<img src=(http:.+?)>")
r2 = Regexp.compile("<a href=(http|ftp).+?>(.+?)</a>")
while line = DATA.gets
[ r1, r2 ].each {|rep|
rep =~ line
p $+
}
end
__END__
<tr> <td><img src=http://localhost/a.jpg></td> <td>ikkou</td> <td...