44件ヒット
[1-44件を表示]
(0.086秒)
検索結果
先頭4件
-
Kernel
. # chomp(rs = $ / ) -> String (18166.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] (13.0) -
外部プログラム cmd を実行し、そのプロセスの標準入力、標準出力、標準エラー 出力に接続されたパイプと実行したプロセスを待つためのスレッドを 4 要素の 配列で返します。
...# オプションを指定した場合。
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| . . . } -> () (13.0) -
外部プログラム cmd を実行し、そのプロセスの標準入力、標準出力、標準エラー 出力に接続されたパイプと実行したプロセスを待つためのスレッドを 4 要素の 配列で返します。
...# オプションを指定した場合。
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 (13.0) -
prompt を出力し、ユーザからのキー入力を待ちます。 エンターキーの押下などでユーザが文字列を入力し終えると、 入力した文字列を返します。 このとき、add_hist が true であれば、入力した文字列を入力履歴に追加します。 何も入力していない状態で EOF(UNIX では ^D) を入力するなどで、 ユーザからの入力がない場合は nil を返します。
...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...