るりまサーチ

最速Rubyリファレンスマニュアル検索!
44件ヒット [1-44件を表示] (0.032秒)
トップページ > クエリ:new[x] > クエリ:line[x] > 種類:クラス[x]

別のキーワード

  1. openssl new
  2. _builtin new
  3. rexml/document new
  4. resolv new
  5. socket new

ライブラリ

キーワード

検索結果

Monitor (37.0)

スレッドの同期機構としてのモニター機能を提供するクラスです。 また同じスレッドから何度も lock できる Mutex としての機能も提供します。

...r'

buf = []
mon = Monitor.new
empty_cond = mon.new_cond

# consumer
Thread.start do
loop do
mon.synchronize do
empty_cond.wait_while { buf.empty? }
print buf.shift
end
end
end

# producer
while line = ARGF.gets
mon.synchronize do
buf.push(line)
empty_cond.signal...
...にならない例][ruby]{
require 'monitor'
mon = Monitor.new
mon.synchronize {
mon.synchronize {
}
}
//}

Thread::Mutex ではデッドロックになります。

//emlist[Mutex でデッドロックになる例][ruby]{
mx = Mutex.new
mx.synchronize {
mx.synchronize {
}
}
# => deadlock; r...

Thread::SizedQueue (19.0)

サイズの最大値を指定できる Thread::Queue です。

...れる行が同じ順序になります。
q = [] にすると入力と違った順序で行が出力されます。

require 'thread'

q = SizedQueue.new(1)

th = Thread.start {
while line = q.pop
print line
end
}

while l = gets
q.push(l)
end
q.push(l)

th.join...

CSV (13.0)

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

...tderr) { |csv_err| csv_err << %w{my data here} } # to $stderr
//}

=== CSV と文字エンコーディング (M17n or Multilingualization)

This new CSV parser is m17n savvy. The parser works in the Encoding of the IO
or String object being read from or written to. Your data is never transcode...
...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 String with an Encoding
that is not ASCII compatibl...
...e. There's no existing data for CSV to use to
prepare itself and thus you will probably need to manually specify the desired
Encoding for most of those cases. It will try to guess using the fields in a
row of output though, when using CSV::generate_line() or Array#to_csv()....

REXML::ParseException (13.0)

XML のパースに失敗したときに生じる例外です。

...XML のパースに失敗したときに生じる例外です。

//emlist[][ruby]{
require 'rexml/document'
begin
REXML::Document.new("<a>foo\n</b></a> ")
rescue REXML::ParseException => ex
ex.position # => 16
ex.line # => 2
ex.context # => [16, 2, 2]
end
//}...