ライブラリ
クラス
- File (33)
- IO (374)
-
OpenSSL
:: BN (11) - StringIO (55)
- Tempfile (50)
-
Zlib
:: GzipWriter (44)
モジュール
- FileTest (11)
- Kernel (269)
- Open3 (22)
-
OpenSSL
:: Buffering (11) - OpenURI (22)
-
OpenURI
:: OpenRead (22) - Syslog (99)
- Timeout (19)
- URI (14)
キーワード
-
$ > (11) -
$ stderr (11) -
$ stdin (11) -
$ stdout (11) - ARGF (11)
- File (11)
-
NEWS for Ruby 2
. 1 . 0 (11) -
NEWS for Ruby 2
. 3 . 0 (9) -
NEWS for Ruby 2
. 5 . 0 (7) -
NEWS for Ruby 2
. 7 . 0 (5) -
NEWS for Ruby 3
. 0 . 0 (4) -
NEWS for Ruby 3
. 1 . 0 (3) - Ruby用語集 (11)
- alert (11)
- bigdecimal (11)
- binread (11)
- binwrite (11)
- create (20)
- crit (11)
- debug (11)
- emerg (11)
- err (11)
- exec (44)
- fail (33)
- file (11)
-
for
_ fd (11) - foreach (22)
- identical? (11)
- info (11)
- log (11)
- new (43)
- notice (11)
- open-uri (6)
-
open
_ uri (22) - popen (154)
- popen3 (22)
-
pretty
_ print (11) - print (11)
- printf (22)
- putc (11)
- puts (11)
- raise (33)
- read (33)
- readlines (33)
- reopen (55)
-
ruby 1
. 6 feature (11) -
ruby 1
. 8 . 2 feature (11) -
ruby 1
. 8 . 5 feature (11) -
ruby 1
. 9 feature (11) - spawn (44)
- sysopen (11)
- timeout (19)
- warning (11)
- write (22)
- xpopen (22)
- クラス/メソッドの定義 (11)
- セキュリティモデル (11)
- 制御構造 (11)
検索結果
先頭5件
-
IO
. new(fd , mode = "r" , **opts) -> IO (44.0) -
オープン済みのファイルディスクリプタ fd に対する新しい IO オブジェクトを生成して返します。
...オープン済みのファイルディスクリプタ fd に対する新しい
IO オブジェクトを生成して返します。
IO.open にブロックが与えられた場合、IO オブジェクトを生成しそれを引数としてブロックを
実行します。ブロックの終了と......ある整数を指定します。
@param mode Kernel.#open と同じ形式で IO のモードを指定します。File::Constants::RDONLY などの
定数(数値)でモードを指定できます。詳細は組み込み関数 Kernel.#open を参照
してください。......io = IO.new(IO.sysopen("testfile"))
io.class # => IO
io.close
//}
//emlist[例:IO.for_fd による読み込み・バイナリモードでのファイルオープン][ruby]{
IO.binwrite("testfile", "\xBF\xAA\x16\x04.\b\xCB\x12\xACoeQ\xFDv2\xCF9+\x81\x18")
io = IO.for_fd(IO.sysopen("testfile"), "r",... -
IO
. read(path , **opt) -> String | nil (42.0) -
path で指定されたファイルを offset 位置から length バイト分読み込んで返します。
...れた場合はバイナリ読み込みメソッド、そうでない場合はテキスト読み込みメソッドとして
動作します。
Kernel.#open と同様 path の先頭が "|" ならば、"|" に続くコマンドの出力を読み取ります。
@param path ファイル名を表す文......F まで読み込みます。
@param offset 読み込みを始めるオフセットを整数で指定します。
@param opt ファイル path を open する時に使われるオプションをキーワード引数で指定します。
@raise Errno::EXXX path のオープン、offset 位置へ......されます。
: :mode
IO.open のモードを指定します。
"r" で始まる文字列である必要があります。
: :open_args
IO.open に渡される引数を配列で指定します。
これらの他、 :external_encoding など
IO.open のオプション引数が指定... -
IO
. read(path , length = nil , **opt) -> String | nil (42.0) -
path で指定されたファイルを offset 位置から length バイト分読み込んで返します。
...れた場合はバイナリ読み込みメソッド、そうでない場合はテキスト読み込みメソッドとして
動作します。
Kernel.#open と同様 path の先頭が "|" ならば、"|" に続くコマンドの出力を読み取ります。
@param path ファイル名を表す文......F まで読み込みます。
@param offset 読み込みを始めるオフセットを整数で指定します。
@param opt ファイル path を open する時に使われるオプションをキーワード引数で指定します。
@raise Errno::EXXX path のオープン、offset 位置へ......されます。
: :mode
IO.open のモードを指定します。
"r" で始まる文字列である必要があります。
: :open_args
IO.open に渡される引数を配列で指定します。
これらの他、 :external_encoding など
IO.open のオプション引数が指定... -
IO
. read(path , length = nil , offset = 0 , **opt) -> String | nil (42.0) -
path で指定されたファイルを offset 位置から length バイト分読み込んで返します。
...れた場合はバイナリ読み込みメソッド、そうでない場合はテキスト読み込みメソッドとして
動作します。
Kernel.#open と同様 path の先頭が "|" ならば、"|" に続くコマンドの出力を読み取ります。
@param path ファイル名を表す文......F まで読み込みます。
@param offset 読み込みを始めるオフセットを整数で指定します。
@param opt ファイル path を open する時に使われるオプションをキーワード引数で指定します。
@raise Errno::EXXX path のオープン、offset 位置へ......されます。
: :mode
IO.open のモードを指定します。
"r" で始まる文字列である必要があります。
: :open_args
IO.open に渡される引数を配列で指定します。
これらの他、 :external_encoding など
IO.open のオプション引数が指定... -
NEWS for Ruby 2
. 1 . 0 (36.0) -
NEWS for Ruby 2.1.0 このドキュメントは前回リリース以降のバグ修正を除くユーザーに影響のある機能の変更のリストです。
...IO#write_nonblock シンボルを返すためにキーワード引数 `exception: false` を受け付けるようになりました
* Kernel
* 追加: Kernel#singleton_method(Object#singleton_method)
* Module
* 追加: Module#using, which activates refinements of the specified module o......び出すと警告するようになりました。
* IO
* 非互換: IO.open は外部エンコーディングが ASCII-8BIT のとき内部エンコーディングを無視します。
* Kernel.#eval, Kernel.#instance_eval, Module#module_eval
元の環境のスコープ情報をコ......jects_from_root
* 追加: ObjectSpace.#dump
* 追加: ObjectSpace.#dump_all
* OpenSSL::BN
* 拡張: OpenSSL::BN.new Fixnum や Bignum を引数として取れるようになりました。
* open-uri
* 複数フィールドに同じ名前を使うことをサポートしまし... -
NEWS for Ruby 3
. 1 . 0 (36.0) -
NEWS for Ruby 3.1.0 このドキュメントは前回リリース以降のバグ修正を除くユーザーに影響のある機能の変更のリストです。
...ます。 10917
* Integer
* 新規メソッド
* Integer.try_convert が追加されました。 15211
* Kernel
* 変更されたメソッド
* Kernel#load が第2引数にモジュールを渡せるようになり、渡されたモジュールをトップレベルのモジ......は fork(2) のコアメソッドです。このメソッドを直接呼び出さないでください。既存のforkメソッド(Kernel.#fork、Process.fork、IO.popen("-"))によって呼び出されます。アプリケーションモニタリングライブラリは、このメソッドを上......* ipaddr 1.2.3
* irb 1.4.1
* json 2.6.1
* logger 1.5.0
* net-http 0.2.0
* net-protocol 0.1.2
* nkf 0.1.1
* open-uri 0.2.0
* openssl 3.0.0
* optparse 0.2.0
* ostruct 0.5.2
* pathname 0.2.0
* pp 0.3.0
* prettyprint 0.1.1
* psych 4.0.3
* ra... -
クラス/メソッドの定義 (36.0)
-
クラス/メソッドの定義 * クラス/メソッドの定義: * class * singleton_class * module * method * operator * nest_method * eval_method * singleton_method * class_method * limit * 定義に関する操作: * alias * undef * defined
...Y = 0
WRONLY = 1
end
include Constants
end
File.open("foo", File::RDONLY)
# あるいは
include File::Constants
File.open("foo", RDONLY)
# 上記はあくまでも例である。実際の File.open ではより簡便な
# File.open("foo", "r") という形式が使われる
//}
クラ......タを定義する方法の一つです。イテレータを定義する代表的な方法は
yield を呼び出すことです。
他に Proc.new/Kernel.#proc を使う方法などもあります。
ブロックが与えられなかった場合のブロック引数の値はnilです。
//emlist[......して以下があります。
//emlist[][ruby]{
defined? yield
//}
yield の呼び出しが可能なら真(文字列 "yield")を返します。
Kernel.#block_given? と同様にメソッドがブロック付きで呼ばれたか
を判断する方法になります。
//emlist[][ruby]{
defined?... -
IO
. binread(path , length = nil , offset = 0) -> String | nil (28.0) -
path で指定したファイルを open し、offset の所まで seek し、 length バイト読み込みます。
...path で指定したファイルを open し、offset の所まで seek し、
length バイト読み込みます。
Kernel.#open と同様 path の先頭が "|" ならば、"|" に続くコマンドの出力を読み取ります。
length を省略するとファイルの末尾まで読み込み... -
Timeout
. # timeout(sec , exception _ class = nil) {|i| . . . } -> object (24.0) -
ブロックを sec 秒の期限付きで実行します。 ブロックの実行時間が制限を過ぎたときは例外 Timeout::Error が発生します。
...値(0.000001のような)に変える。
timeout による割り込みは Kernel.#system によって呼び出された外部プログラムを
タイムアウトさせる事はできないので、IO.popen、Kernel.#openを使用するなどの工夫が必要です。
例 外部コマンドの......タイムアウト
require 'timeout'
# テスト用のシェルをつくる。
File.open("loop.sh", "w"){|fp|
fp.print <<SHELL_EOT
#!/bin/bash
S="scale=10"
M=32767
trap 'echo "$S; $m1/($m1+$m2)*4" | bc ; echo "count = $((m1+m2))" ; exit 0' INT
m1=0
m2=0
while true
do......ト
begin
pid = nil
com = nil
Timeout.timeout(t) {
# system だととまらない
# system("./loop.sh")
com = IO.popen("./loop.sh")
pid = com.pid
while line = com.gets
print line
end
}
rescue Timeout::Error => err
puts "timeout: she... -
Timeout
. # timeout(sec , exception _ class , message) {|i| . . . } -> object (24.0) -
ブロックを sec 秒の期限付きで実行します。 ブロックの実行時間が制限を過ぎたときは例外 Timeout::Error が発生します。
...値(0.000001のような)に変える。
timeout による割り込みは Kernel.#system によって呼び出された外部プログラムを
タイムアウトさせる事はできないので、IO.popen、Kernel.#openを使用するなどの工夫が必要です。
例 外部コマンドの......タイムアウト
require 'timeout'
# テスト用のシェルをつくる。
File.open("loop.sh", "w"){|fp|
fp.print <<SHELL_EOT
#!/bin/bash
S="scale=10"
M=32767
trap 'echo "$S; $m1/($m1+$m2)*4" | bc ; echo "count = $((m1+m2))" ; exit 0' INT
m1=0
m2=0
while true
do......ト
begin
pid = nil
com = nil
Timeout.timeout(t) {
# system だととまらない
# system("./loop.sh")
com = IO.popen("./loop.sh")
pid = com.pid
while line = com.gets
print line
end
}
rescue Timeout::Error => err
puts "timeout: she... -
bigdecimal (24.0)
-
bigdecimal は浮動小数点数演算ライブラリです。 任意の精度で 10 進表現された浮動小数点数を扱えます。
...) #=> Infinity
BigDecimal("-1.0") / BigDecimal("0.0") #=> -Infinity
//}
無限大を表す BigDecimal オブジェクトを作成する場合、
Kernel.#BigDecimal の引数に "Infinity" や "-Infinity" を指定して
ください。(大文字小文字を区別します)
//emlist[][ruby]{
requ......ruby]{
require "bigdecimal"
BigDecimal("0.0") / BigDecimal("0.0") # => NaN
//}
NaN を表す BigDecimal オブジェクトを作成する場合、
Kernel.#BigDecimal の引数に "NaN" を指定してください。(大文字小文
字を区別します)
//emlist[][ruby]{
require "bigdecimal"
BigD......txt][ruby]{
0.1
0.1
0.1
//}
//emlist[][ruby]{
require "bigdecimal"
File::open("digits.txt", "r") do |file|
s = BigDecimal("0")
while line = file.gets
s = s + BigDecimal(line)
end
puts s # => 0.3e0
end
File::open("digits.txt", "r") do |file|
s = 0
while line = file.gets
s = s +...