Ruby 1.9.3 リファレンスマニュアル > ライブラリ一覧 > shellライブラリ > Shellクラス > transact

instance method Shell#transact

transact { ... } -> object

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

例:

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