23件ヒット
[1-23件を表示]
(0.083秒)
検索結果
先頭3件
-
Shell
:: Filter # transact { . . . } -> object (21213.0) -
ブロック中で shell を self として実行します。
...ブロック中で 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 と同じとなる。
}... -
PStore
# transaction(read _ only = false) {|pstore| . . . } -> object (12300.0) -
トランザクションに入ります。 このブロックの中でのみデータベースの読み書きができます。
...クで最後に評価した値を返します。
@raise PStore::Error read_only を真にしたときに、データベースを変更しようした場合に発生します。
例:
require 'pstore'
db = PStore.new("/tmp/foo")
db.transaction do
p db.roots # => []
ary = db["roo......t"] = [1,2,3,4]
ary[0] = [1,1.5]
end
db.transaction(true) do |pstore|
pstore["root"] = 'aaa' # => ここで例外発生
end... -
Shell
:: Filter # |(filter) -> object (3236.0) -
パイプ結合を filter に対して行います。
...ilter に対して行います。
@param filter Shell::Filter オブジェクトを指定します。
@return filter を返します。
使用例
require 'shell'
Shell.def_system_command("tail")
Shell.def_system_command("head")
Shell.def_system_command("wc")
sh = Shell.new
sh.transact......{
i = 1
while i <= (cat("/etc/passwd") | wc("-l")).to_s.chomp.to_i
puts (cat("/etc/passwd") | head("-n #{i}") | tail("-n 1")).to_s
i += 1
end
}...