るりまサーチ

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

別のキーワード

  1. _builtin puts
  2. csv puts
  3. stringio puts
  4. zlib puts
  5. io puts

ライブラリ

クラス

モジュール

キーワード

検索結果

<< 1 2 > >>

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

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

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

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

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

require 'zlib'

filename='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.8.4 feature (144.0)

ruby 1.8.4 feature ruby 1.8.4 での ruby 1.8.3 からの変更点です。

...hod#bind [bug]>))
* ((<ruby 1.8.4 feature/set_trace_func [bug]>))
* ((<ruby 1.8.4 feature/set_trace_func [change]>))
* ((<ruby 1.8.4 feature/printf [bug]>))
* ((<ruby 1.8.4 feature/Hash [bug]>))
* ((<ruby 1.8.4 feature/test [bug]>))
* ((<ruby 1.8.4 feature/File.identical? [new]>))
* ((...
...ns invalid symbol representations:

puts
:"!".inspect
puts
:"=".inspect
puts
:"0".inspect
puts
:"$1".inspect
puts
:"@1".inspect
puts
:"@@1".inspect
puts
:"@".inspect
puts
:"@@".inspect

# => r...
..."
:"@"
:"@@"

3) Symbol#inspect sometimes returns suboptimal symbol representations:
puts
:foo!.inspect
puts
:bar?.inspect

# => ruby 1.8.3 (2005-09-21) [i686-linux]
:"foo!"
:"bar?"...

ruby 1.6 feature (72.0)

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

...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)...
...シグナルを送らないと終了しない不具合が修正さ
れました。((<ruby-bugs-ja:PR#223>))

trap(:TERM, "EXIT")

END{
puts
"exit"
}

Thread.start { Thread.stop }
sleep

: 2002-04-17: Regexp#inspect

((<ruby-bugs-ja:PR#222>))

p %r{\/}

=> ruby 1...
...1
2

: String#succ

((<ruby-talk:22557>))

p "***".succ
p "*".succ
p sprintf("%c", 255).succ
p sprintf("*%c", 255).succ
p sprintf("**%c", 255).succ

=> ruby 1.6.5 (2001-09-19) [i586-linux]
"**+"
"\001+"...

Net::SMTP#open_message_stream(from_addr, *to_addrs) {|f| .... } -> () (42.0)

メール書き込みの準備をし、書き込み先のストリームオブジェクトを ブロックに渡します。ブロック終了後、書きこんだ結果が 送られます。

...れるストリームオブジェクトは以下のメソッドを持っています。
* puts(str = '') strを出力して CR LFを出力
* print(str) strを出力
* printf(fmt, *args) sprintf(fmt,*args) を出力
* write(str):: str を出力して書き込んだバイト数...
...{|smtp|
smtp.open_message_stream('from@example.com', 'to@example.net') {|f|
f.puts 'From: from@example.com'
f.puts 'To: to@example.net'
f.puts 'Subject: test mail'
f.puts
f.puts 'This is test mail.'
}
}

ready は obsolete です。

@param from_addr 送信...

Net::SMTP#ready(from_addr, *to_addrs) {|f| .... } -> () (42.0)

メール書き込みの準備をし、書き込み先のストリームオブジェクトを ブロックに渡します。ブロック終了後、書きこんだ結果が 送られます。

...れるストリームオブジェクトは以下のメソッドを持っています。
* puts(str = '') strを出力して CR LFを出力
* print(str) strを出力
* printf(fmt, *args) sprintf(fmt,*args) を出力
* write(str):: str を出力して書き込んだバイト数...
...{|smtp|
smtp.open_message_stream('from@example.com', 'to@example.net') {|f|
f.puts 'From: from@example.com'
f.puts 'To: to@example.net'
f.puts 'Subject: test mail'
f.puts
f.puts 'This is test mail.'
}
}

ready は obsolete です。

@param from_addr 送信...

絞り込み条件を変える

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

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

...min[1] += 1
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

例 独自の例外を発生させ...
...quire 'timeout'

class MYError < Exception;end
begin
Timeout.timeout(5, MYError) {
sleep(30)
}
rescue MYError => err
puts
"MYError"
puts
err
end

=== 注意

timeout による割り込みは Thread によって実現されています。
C 言語レベルで実装され...
...pid = com.pid
while line = com.gets
print line
end
}
rescue Timeout::Error => err
puts
"timeout: shell execution."
Process.kill('SIGINT', pid)
printf
"[result]\t%s", com.read
com.close unless com.nil?
end

#止まっているか確認する。
#syst...

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

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

...min[1] += 1
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

例 独自の例外を発生させ...
...quire 'timeout'

class MYError < Exception;end
begin
Timeout.timeout(5, MYError) {
sleep(30)
}
rescue MYError => err
puts
"MYError"
puts
err
end

=== 注意

timeout による割り込みは Thread によって実現されています。
C 言語レベルで実装され...
...pid = com.pid
while line = com.gets
print line
end
}
rescue Timeout::Error => err
puts
"timeout: shell execution."
Process.kill('SIGINT', pid)
printf
"[result]\t%s", com.read
com.close unless com.nil?
end

#止まっているか確認する。
#syst...

Zlib::GzipReader#lineno -> Integer (30.0)

IO クラスの同名メソッドIO#linenoと同じです。

...作成できる。
Zlib::GzipWriter.open('hoge.gz') { |gz|
gz.puts 'h'
gz.puts 'o'
gz.puts 'g'
gz.puts 'e'
}
=end

Zlib::GzipReader.open('hoge.gz') { |gz|
while l = gz.gets
l.chomp!
printf
"%s %d\n", l, gz.lineno
end
}
#=> h 1
#=> o 2
#=> g 3
#=>...

Zlib::GzipReader#lineno=(num) (30.0)

IO クラスの同名メソッドIO#lineno=と同じです。

...
Zlib::GzipWriter.open('hoge.gz') { |gz|
gz.puts 'h'
gz.puts 'o'
gz.puts 'g'
gz.puts 'e'
}
=end

Zlib::GzipReader.open('hoge.gz') { |gz|
while l = gz.gets
l.chomp!
gz.lineno = 1000 if l == "o"
printf
"%s %d\n", l, gz.lineno
end
}
#=> h 1
#=>...
<< 1 2 > >>