44件ヒット
[1-44件を表示]
(0.103秒)
検索結果
先頭4件
-
Kernel
. # chomp(rs = $ / ) -> String (24266.0) -
$_.chomp とほぼ同じですが、置換が発生したときは、$_の内容を置き換える点が異なります。 コマンドラインオプションで -p または -n を指定した時のみ定義されます。
...$_.chomp とほぼ同じですが、置換が発生したときは、$_の内容を置き換える点が異なります。
コマンドラインオプションで -p または -n を指定した時のみ定義されます。
暗号的になりすぎるきらいがあるため、このメソッド......の使用は推奨されていません。
今後はより明示的な $_.chomp を使ってください。
$_.chomp とこのメソッド chomp は以下の点で違いがあります。
* chomp は $_ の値をコピーして、コピーの方を更新し、
$_ に再代入します。
@par......//emlist[例: ruby -n で "test" を入力][ruby]{
$_ # => "test\n"
chomp # => "test"
//}
//emlist[例: ruby -n で "test," を入力し、 rs に "," を指定][ruby]{
$_ # => "test\n"
chomp # => "test,"
chomp(",") # => "test"
//}
@see String#chomp,$_,$/... -
Open3
. # popen3(*cmd) -> [IO , IO , IO , Thread] (113.0) -
外部プログラム cmd を実行し、そのプロセスの標準入力、標準出力、標準エラー 出力に接続されたパイプと実行したプロセスを待つためのスレッドを 4 要素の 配列で返します。
...と実行したプロセスを待つためのスレッドを 4 要素の
配列で返します。
require 'open3'
stdin, stdout, stderr, wait_thr = *Open3.popen3("/usr/bin/nroff -man")
@param cmd 実行するコマンドを指定します。
@return ブロックを指定した場合はブロ......この場合はブロックの最後の式の結果を返します。
require 'open3'
Open3.popen3("read stdin; echo stdout; echo stderr >&2") {|stdin, stdout, stderr, wait_thr|
stdin.puts "stdin"
stdin.close # または close_write
p stdout.read
p stderr.read
}
#=> "st......# オプションを指定した場合。
Dir.chdir("/tmp")
Open3.popen3("pwd", :chdir=> "/") {|i,o,e,t|
p o.read.chomp #=> "/"
}
# オプションを指定しない場合。
Dir.chdir("/tmp")
Open3.popen3("pwd") {|i,o,e,t|
p o.read.chomp #=> "/tmp"
}
@see Kernel.#spawn... -
Open3
. # popen3(*cmd) {|stdin , stdout , stderr , wait _ thr| . . . } -> () (113.0) -
外部プログラム cmd を実行し、そのプロセスの標準入力、標準出力、標準エラー 出力に接続されたパイプと実行したプロセスを待つためのスレッドを 4 要素の 配列で返します。
...と実行したプロセスを待つためのスレッドを 4 要素の
配列で返します。
require 'open3'
stdin, stdout, stderr, wait_thr = *Open3.popen3("/usr/bin/nroff -man")
@param cmd 実行するコマンドを指定します。
@return ブロックを指定した場合はブロ......この場合はブロックの最後の式の結果を返します。
require 'open3'
Open3.popen3("read stdin; echo stdout; echo stderr >&2") {|stdin, stdout, stderr, wait_thr|
stdin.puts "stdin"
stdin.close # または close_write
p stdout.read
p stderr.read
}
#=> "st......# オプションを指定した場合。
Dir.chdir("/tmp")
Open3.popen3("pwd", :chdir=> "/") {|i,o,e,t|
p o.read.chomp #=> "/"
}
# オプションを指定しない場合。
Dir.chdir("/tmp")
Open3.popen3("pwd") {|i,o,e,t|
p o.read.chomp #=> "/tmp"
}
@see Kernel.#spawn... -
Readline
. # readline(prompt = "" , add _ hist = false) -> String | nil (113.0) -
prompt を出力し、ユーザからのキー入力を待ちます。 エンターキーの押下などでユーザが文字列を入力し終えると、 入力した文字列を返します。 このとき、add_hist が true であれば、入力した文字列を入力履歴に追加します。 何も入力していない状態で EOF(UNIX では ^D) を入力するなどで、 ユーザからの入力がない場合は nil を返します。
...。
エンターキーの押下などでユーザが文字列を入力し終えると、
入力した文字列を返します。
このとき、add_hist が true であれば、入力した文字列を入力履歴に追加します。
何も入力していない状態で EOF(UNIX では ^D) を入......は Emacs モードです。
@param prompt カーソルの前に表示する文字列を指定します。デフォルトは""です。
@param add_hist 真ならば、入力した文字列をヒストリに記録します。デフォルトは偽です。
@raise IOError 標準入力が tty でな......stty_save = `stty -g`.chomp
begin
while buf = Readline.readline
p buf
end
rescue Interrupt
system("stty", stty_save)
exit
end
例: INTシグナルを捕捉して、端末状態を復帰する。
require 'readline'
stty_save = `stty -g`.chomp
trap("INT") { syste...