るりまサーチ

最速Rubyリファレンスマニュアル検索!
48件ヒット [1-48件を表示] (0.086秒)
トップページ > クエリ:r[x] > クラス:Shell[x] > ライブラリ:shell[x] > クエリ:transact[x]

別のキーワード

  1. _builtin to_r
  2. open3 pipeline_r
  3. matrix elements_to_r
  4. fileutils cp_r
  5. fileutils rm_r

検索結果

Shell#transact { ... } -> object (24216.0)

ブロック中で shell を self として実行します。

...ブロック中で shell を self として実行します。

例:

r
equire 'shell'
Shell
.def_system_command("head")
sh = Shell.new
sh.transact{
system("ls", "-l") | head > STDOUT
# transact の中では、
# sh.system("ls", "-l") | sh.head > STDOUT と同じとなる。
}...

Shell#chdir(path, &block) -> self (3109.0)

カレントディレクトリをpathにする. イテレータとして呼ばれたときには ブロック実行中のみカレントディレクトリを変更する.

...レクトリを変更する.

@param path カレントディレクトリを文字列で指定します.

@param block path で指定したディレクトリで行う操作をブロックで指定します.

使用例
r
equire 'shell'
sh = Shell.new
sh.transact {
cd("/tmp"){
p cwd #=...
...> "/tmp"
}
p cwd #=> "/Users/kouya/rbmanual"
}...

Shell#cat(*files) -> Shell::Filter (109.0)

実行すると, それらを内容とする Filter オブジェクトを返します.

...それらを内容とする Filter オブジェクトを返します.

@param files シェルコマンド cat に与えるファイル名を文字列で指定します。

動作例
r
equire 'shell'
Shell
.def_system_command("head")
sh = Shell.new
sh.transact {
glob("*.txt").to_a.each { |...

Shell#echo(*strings) -> Shell::Filter (109.0)

実行すると, それらを内容とする Filter オブジェクトを返します.

..., それらを内容とする Filter オブジェクトを返します.

@param strings シェルコマンド echo に与える引数を文字列で指定します。

動作例
r
equire 'shell'
Shell
.def_system_command("head")
sh = Shell.new
sh.transact {
glob("*.txt").to_a.each { |file|...

Shell#glob(pattern) -> Shell::Filter (109.0)

実行すると, それらを内容とする Filter オブジェクトを返します.

...ilter オブジェクトを返します.

@param pattern シェルコマンド glob に与えるパターンを指定します。
パターンの書式については、Dir.[] を参照してください。

動作例
r
equire 'shell'
Shell
.def_system_command("head")
sh = Shell.ne...
...w
sh.transact {
glob("*.txt").to_a.each { |file|
file.chomp!
cat(file).each { |l|
echo(l) | tee(file + ".tee") >> "all.tee"
}
}
}

@see Dir.[]...

絞り込み条件を変える

Shell#tee(file) -> Shell::Filter (109.0)

実行すると, それらを内容とする Filter オブジェクトを返します.

..., それらを内容とする Filter オブジェクトを返します.

@param file シェルコマンドtee に与えるファイル名を文字列で指定します。

動作例
r
equire 'shell'
Shell
.def_system_command("head")
sh = Shell.new
sh.transact {
glob("*.txt").to_a.each { |f...

Shell.install_system_commands(pre = "sys_") -> () (109.0)

system_path上にある全ての実行可能ファイルをShellに定義する. メソッ ド名は元のファイル名の頭にpreをつけたものとなる.

...イルをShellに定義する. メソッ
ド名は元のファイル名の頭にpreをつけたものとなる.

@param pre Shellに定義するメソッド名の先頭に付加される文字列を指定します。

使用例: ls -l | head -n 5 のような例。

r
equire 'shell'
Shell
.install...
..._system_commands
sh = Shell.new
sh.verbose = false
sh.transact {
(sys_ls("-l") | sys_head("-n 5")).each {|l|
puts l
}
}...

Shell.undef_system_command(command) -> Shell::CommandProcessor (109.0)

commandを削除します.

...andを削除します.

@param command 削除するコマンドの文字列を指定します。

動作例:
r
equire 'shell'
Shell
.def_system_command("ls")
# ls を定義
Shell
.undef_system_command("ls")
# ls を 削除

sh = Shell.new
begin
sh.transact {
ls("-l").each {|l|...
...puts l
}
}
r
escue NameError => err
puts err
end...