るりまサーチ

最速Rubyリファレンスマニュアル検索!
348件ヒット [301-348件を表示] (0.077秒)
トップページ > クエリ:-[x] > クエリ:foreach[x]

別のキーワード

  1. _builtin -
  2. open-uri open
  3. irb/input-method new
  4. irb/input-method gets
  5. matrix -

ライブラリ

クラス

モジュール

キーワード

検索結果

<< < ... 2 3 4 >>

IO (102.0)

基本的な入出力機能のためのクラスです。

...の影響をうけます。
詳しくは「io_encoding」を参照して下さい。
以下がテキスト読み込みメソッドです。

* IO.foreach
* IO.readlines
* IO#each_line
* IO#lines
* IO#gets
* IO#getc
* IO#ungetc
* IO#read
* IO#readchar
* IO#readline
* IO#readlines

バイ...
...リ読み込みメソッドは IO のエンコーディングの影響を受けません。
返す文字列のエンコーディングは常に ASCII-8BIT になります。
以下がバイナリ読み込みメソッドです。

* IO#read(size)
* IO#read_nonblock
* IO#readpartial
* IO#sysread...
...はエンコーディングの影響を受けません。
常に1バイトを単位として動作します。

例:

f = File.open('t.txt', 'r+:euc-jp')
p f.getc.encoding #=> Encoding::EUC_JP
p f.read(1).encoding #=> Encoding::ASCII_8BIT...

logger (96.0)

ログを記録するためのライブラリです。

...ger::WARN

logger.debug("Created logger")
logger.info("Program started")
logger.warn("Nothing to do!")

path = "a_non_existent_file"

begin
File.foreach(path) do |line|
unless line =~ /^(\w+) = (.*)$/
logger.error("Line in wrong format: #{line.chomp}")
end
end
rescue => err
logge...
...17-12-07T02:22:53.649000 #11601] WARN -- : Nothing to do!
F, [2017-12-07T02:22:53.649172 #11601] FATAL -- : Caught exception; exiting
F, [2017-12-07T02:22:53.649222 #11601] FATAL -- : No such file or directory @ rb_sysopen - a_non_existent_file (Errno::ENOENT)
logger_sample.rb:12:in `foreach'...
... -- ProgName: message

例:

I, [1999-03-03T02:34:24.895701 #19074] INFO -- Main: info.

Logger#datetime_format= を用いてログに記録する時の日時のフォーマッ
トを変更することもできます。

//emlist[][ruby]{
logger.datetime_format = '%Y-%m-%d %H:%M:%S'
# e.g. "2004-...

NEWS for Ruby 2.6.0 (72.0)

NEWS for Ruby 2.6.0 このドキュメントは前回リリース以降のバグ修正を除くユーザーに影響のある機能の変更のリストです。

...は参照情報があるため短いです。
十分な情報と共に書かれた全ての変更のリストは ChangeLog ファイルか bugs.ruby-lang.org の issue を参照してください。

== 2.5.0 以降の変更

=== 言語仕様の変更

* $SAFE はプロセスグローバルで扱...
...ができます。 12912
典型的なユースケースは以下の通りです:
//emlist{
ary[1..] # ary[1..-1] と同じ
(1...).each {|index| block } # index が 1 から始まる無限ループ
ary.zip(1..) {|elem, index| block } # ar...
...推奨になる予定で、
今は警告が出ます。 14643

* File
* File.read, File.binread, File.write, File.binwrite,
File.foreach, File.readlines はパスがパイプ文字 '|' で始まっていても
外部コマンドを実行しなくなりました。 14245

*...

NEWS for Ruby 2.4.0 (66.0)

NEWS for Ruby 2.4.0 このドキュメントは前回リリース以降のバグ修正を除くユーザーに影響のある機能の変更のリストです。

...は参照情報があるため短いです。
十分な情報と共に書かれた全ての変更のリストは ChangeLog ファイルか bugs.ruby-lang.org の issue を参照してください。

== 2.3.0 以降の変更

=== 言語仕様の変更

* 条件式での多重代入ができるよ...
...half には :even, :up, :down が指定可能です。 12548 12958 12953

* IO
* IO#gets, IO#readline, IO#each_line, IO#readlines, IO.foreach
chomp というキーワード引数を受け付けるようになりました。12553

* Kernel
* Kernel#clone は freeze とい...
...by 2.4.0)
* Onigmo 6.1.1 に更新 (Ruby 2.4.1)
* 非包含オペレータ(absence operator)をサポートしました https://github.com/k-takata/Onigmo/issues/82

* Regexp/String: Unicodeのバージョンを8.0.0から9.0.0に更新しました 12513

* RubyVM::Env
* 削除し...

CSV (24.0)

このクラスは CSV ファイルやデータに対する完全なインターフェイスを提供します。

...by]{
require "csv"

csv_text = <<~CSV_TEXT
Ruby,1995
Rust,2010
CSV_TEXT

IO.write "sample.csv", csv_text

# ファイルから一行ずつ
CSV.foreach("sample.csv") do |row|
p row
end
# => ["Ruby", "1995"]
# ["Rust", "2010"]

# ファイルから一度に
p CSV.read("sample.csv")
# => [["Ru...
...important to note that while all of CSV's core parser is now
Encoding agnostic, some features are not. For example, the built-in
converters will try to transcode data to UTF-8 before making conversions.
Again, you can provide custom converters that are aware of your Encodings to
avoid this translat...
...d String objects
passed into CSV have the proper Encoding set and everything should just work.
CSV methods that allow you to open IO objects (CSV::foreach(), CSV::open(),
CSV::read(), and CSV::readlines()) do allow you to specify the Encoding.

One minor exception comes when generating CSV into a St...

絞り込み条件を変える

Open3 (12.0)

プログラムを実行し、そのプロセスの標準入力・標準出力・ 標準エラー出力にパイプをつなぎます。

...標準出力から処理結果を受け取る。

require "open3"

stdin, stdout, stderr = *Open3.popen3('nroff -man')
# こちらから書く
Thread.fork {
File.foreach('/usr/man/man1/ruby.1') do |line|
stdin.print line
end
stdin.close # または close_write
}
#...
<< < ... 2 3 4 >>