るりまサーチ

最速Rubyリファレンスマニュアル検索!
57件ヒット [1-57件を表示] (0.033秒)
トップページ > クエリ:file[x] > クエリ:open[x] > クエリ:printf[x]

別のキーワード

  1. _builtin file?
  2. _builtin file
  3. file open
  4. file truncate
  5. file path

ライブラリ

クラス

モジュール

キーワード

検索結果

Zlib::GzipWriter#printf(format, *args) -> nil (18159.0)

C 言語の printf と同じように、format に従い引数 を文字列に変換して、自身に出力します。

...C 言語の printf と同じように、format に従い引数
を文字列に変換して、自身に出力します。

@param format フォーマット文字列を指定します。print_format を参照してください。

@param args フォーマットされるオブジェクトを指定し...
...

require 'zlib'

file
name='hoge1.gz'
fw = File.open(filename, "w")
Zlib::GzipWriter.wrap(fw, Zlib::BEST_COMPRESSION){|gz|
gz.printf("\n%9s", "bar")
}
fr = File.open(filename)
Zlib::GzipReader.wrap(fr){|gz|
puts gz.read
}
#=> bar

@see IO#printf, Kernel.#printf...

ruby 1.6 feature (240.0)

ruby 1.6 feature ruby version 1.6 は安定版です。この版での変更はバグ修正がメイン になります。

...ったため、enq などを
呼び出したときスーパークラス Queue の enq が実行されていました。

: 2002-09-11: ((<tempfile/Tempfile#size>))

追加 ((<ruby-dev:17221>))

: 2002-09-09

mswin32 版と mingw32 版の ruby で、1.6.6の頃から ruby の子プロセスに...
...1.6.7 (2002-07-30) [i586-linux]

: 2002-06-03 sprintf()

"%d" で引数を整数にするときに、((<組み込み関数/Integer>)) と同じ規則を
使用するようになりました。

p sprintf("%d", nil)

=> -:1:in `sprintf': no implicit conversion from nil (TypeError)...
...dev:17155>))

open
("|-","r+") {|f|
if f
f.dup.close_write
else
sleep 1
end
}

=> ruby 1.6.7 (2002-03-01) [i586-linux]
-:3:in `close_write': closing non-duplex IO for writing (IOError)
from -:3
from -:1:in `open'...

Timeout.#timeout(sec, exception_class = nil) {|i| ... } -> object (36.0)

ブロックを sec 秒の期限付きで実行します。 ブロックの実行時間が制限を過ぎたときは例外 Timeout::Error が発生します。

...end
end

t = 5
min = [ 0, 0]
begin
Timeout.timeout(t){
calc_pi(min)
}
rescue Timeout::Error
puts "timeout"
end

printf
"%d: pi = %f\n", min[0] + min[1], min[0]*4.0/(min[0]+min[1])
#例
#=> 417519: pi = 3.141443

例 独自の例外を発生させるタイム...
...イムアウトさせる事はできないので、IO.popen、Kernel.#openを使用するなどの工夫が必要です。

例 外部コマンドのタイムアウト
require 'timeout'

# テスト用のシェルをつくる。
File
.open("loop.sh", "w"){|fp|
fp.print <<SHELL_EOT
#!/bin/...
...let m2++
fi
done
SHELL_EOT
}

File
.chmod(0755, "loop.sh")
t = 10 # 10 秒でタイムアウト
begin
pid = nil
com = nil
Timeout.timeout(t) {
# system だととまらない
# system("./loop.sh")
com = IO.popen("./loop.sh")
pid = com.pid
w...

Timeout.#timeout(sec, exception_class, message) {|i| ... } -> object (36.0)

ブロックを sec 秒の期限付きで実行します。 ブロックの実行時間が制限を過ぎたときは例外 Timeout::Error が発生します。

...end
end

t = 5
min = [ 0, 0]
begin
Timeout.timeout(t){
calc_pi(min)
}
rescue Timeout::Error
puts "timeout"
end

printf
"%d: pi = %f\n", min[0] + min[1], min[0]*4.0/(min[0]+min[1])
#例
#=> 417519: pi = 3.141443

例 独自の例外を発生させるタイム...
...イムアウトさせる事はできないので、IO.popen、Kernel.#openを使用するなどの工夫が必要です。

例 外部コマンドのタイムアウト
require 'timeout'

# テスト用のシェルをつくる。
File
.open("loop.sh", "w"){|fp|
fp.print <<SHELL_EOT
#!/bin/...
...let m2++
fi
done
SHELL_EOT
}

File
.chmod(0755, "loop.sh")
t = 10 # 10 秒でタイムアウト
begin
pid = nil
com = nil
Timeout.timeout(t) {
# system だととまらない
# system("./loop.sh")
com = IO.popen("./loop.sh")
pid = com.pid
w...

NKF (30.0)

nkf(Network Kanji code conversion Filter, https://osdn.net/projects/nkf/) を Ruby から使うためのモジュールです。

...=> "UTF8",
NKF::BINARY => "BINARY",
NKF::ASCII => "ASCII",
NKF::UNKNOWN => "UNKNOWN",
}

while file = ARGV.shift
str = open(file) {|io| io.gets(nil) }

printf
"%-10s ", file
if str.nil?
puts "EMPTY"
else
puts CODES.fetch(NKF.guess(str))
end
end
//}

=== オプショ...

絞り込み条件を変える