るりまサーチ (Ruby 2.5.0)

最速Rubyリファレンスマニュアル検索!
26件ヒット [1-26件を表示] (0.116秒)

別のキーワード

  1. openssl new
  2. _builtin new
  3. rexml/document new
  4. resolv new
  5. socket new

ライブラリ

クラス

キーワード

検索結果

Shell#transact { ... } -> object (54361.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 と同じとなる。
}

Shell::CommandProcessor#transact { ... } -> object (54361.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 と同じとなる。
}

Shell::Filter#transact { ... } -> object (54361.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 (18322.0)

トランザクションに入ります。 このブロックの中でのみデータベースの読み書きができます。

トランザクションに入ります。
このブロックの中でのみデータベースの読み書きができます。

読み込み専用のトランザクションが使用可能です。

@param read_only 真を指定すると、読み込み専用のトランザクションになります。

@return ブロックで最後に評価した値を返します。

@raise PStore::Error read_only を真にしたときに、データベースを変更しようした場合に発生します。

例:

require 'pstore'
db = PStore.new("/tmp/foo")
db.transaction do
p db.roots...

Shell#out(dev = STDOUT, &block) -> () (88.0)

Shell#transact を呼び出しその結果を dev に出力します。

Shell#transact を呼び出しその結果を dev に出力します。

@param dev 出力先をIO オブジェクトなどで指定します。

@param block transact 内部で実行するシェルを指定します。


使用例:
require 'shell'
Shell.def_system_command("head")
sh = Shell.new
File.open("out.txt", "w"){ |fp|
sh.out(fp) {
system("ls", "-l") | head("-n 3")
}
}

絞り込み条件を変える

Shell::CommandProcessor#out(dev = STDOUT, &block) -> () (88.0)

Shell#transact を呼び出しその結果を dev に出力します。

Shell#transact を呼び出しその結果を dev に出力します。

@param dev 出力先をIO オブジェクトなどで指定します。

@param block transact 内部で実行するシェルを指定します。


使用例:
require 'shell'
Shell.def_system_command("head")
sh = Shell.new
File.open("out.txt", "w"){ |fp|
sh.out(fp) {
system("ls", "-l") | head("-n 3")
}
}

Shell::Filter#out(dev = STDOUT, &block) -> () (88.0)

Shell#transact を呼び出しその結果を dev に出力します。

Shell#transact を呼び出しその結果を dev に出力します。

@param dev 出力先をIO オブジェクトなどで指定します。

@param block transact 内部で実行するシェルを指定します。


使用例:
require 'shell'
Shell.def_system_command("head")
sh = Shell.new
File.open("out.txt", "w"){ |fp|
sh.out(fp) {
system("ls", "-l") | head("-n 3")
}
}

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

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

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

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

動作例
require 'shell'
Shell.def_system_command("head")
sh = Shell.new
sh.transact {
glob("*.txt").to_a.each { |file|
file.chomp!
cat(file).each { |l|
echo(l) | tee(file + ".tee") >> "al...

Shell#cd(path, &block) -> self (40.0)

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

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

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

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

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

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

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

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

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

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

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

絞り込み条件を変える

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

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

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

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

動作例
require 'shell'
Shell.def_system_command("head")
sh = Shell.new
sh.transact {
glob("*.txt").to_a.each { |file|
file.chomp!
cat(file).each { |l|
echo(l) | tee(file + ".tee") >> "al...

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

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

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

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

動作例
require 'shell'
Shell.def_system_command("head")
sh = Shell.new
sh.transact {
glob("*.txt").to_a.each { |file|
file.chomp!
cat(file).each { |l|
...

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

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

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

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

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

Shell::CommandProcessor#cat(*files) -> Shell::Filter (40.0)

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

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

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

動作例
require 'shell'
Shell.def_system_command("head")
sh = Shell.new
sh.transact {
glob("*.txt").to_a.each { |file|
file.chomp!
cat(file).each { |l|
echo(l) | tee(file + ".tee") >> "al...

Shell::CommandProcessor#echo(*strings) -> Shell::Filter (40.0)

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

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

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

動作例
require 'shell'
Shell.def_system_command("head")
sh = Shell.new
sh.transact {
glob("*.txt").to_a.each { |file|
file.chomp!
cat(file).each { |l|
echo(l) | tee(file + ".tee") >> "al...

絞り込み条件を変える

Shell::CommandProcessor#glob(pattern) -> Shell::Filter (40.0)

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

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

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

動作例
require 'shell'
Shell.def_system_command("head")
sh = Shell.new
sh.transact {
glob("*.txt").to_a.each { |file|
file.chomp!
cat(file).each { |l|
...

Shell::CommandProcessor#tee(file) -> Shell::Filter (40.0)

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

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

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

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

Shell::Filter#<(src) -> self (40.0)

srcをフィルタの入力とする。 srcが, 文字列ならばファイルを, IOオブジェクトであれ ばそれをそのまま入力とする。

srcをフィルタの入力とする。 srcが, 文字列ならばファイルを, IOオブジェクトであれ
ばそれをそのまま入力とする。

@param src フィルタの入力を, 文字列もしくは,IO オブジェクトで指定します。

使用例
require 'shell'
Shell.def_system_command("head")
sh = Shell.new
sh.transact {
(sh.head("-n 30") < "/etc/passwd") > "ugo.txt"
}

Shell::Filter#>(to) -> self (40.0)

toをフィルタの出力とする。 toが, 文字列ならばファイルに, IOオブジェクトであれ ばそれをそのまま出力とする。

toをフィルタの出力とする。 toが, 文字列ならばファイルに, IOオブジェクトであれ
ばそれをそのまま出力とする。

@param to 出力先を指定します。文字列ならばファイルに,IOオブジェクトならばそれに出力します。

使用例
require 'shell'
Shell.def_system_command("tail")
sh = Shell.new
sh.transact {
(sh.tail("-n 3") < "/etc/passwd") > File.open("tail.out", "w")
#(sh.tail("-n 3") < "/e...

Shell::Filter#>>(to) -> self (40.0)

toをフィルタに追加する。 toが, 文字列ならばファイルに, IOオブジェクトであれば それをそのまま出力とする。

toをフィルタに追加する。 toが, 文字列ならばファイルに, IOオブジェクトであれば
それをそのまま出力とする。

@param to 出力先を指定します。文字列ならばファイルに、IOオブジェクトならばそれに出力します。

使用例
require 'shell'
Shell.def_system_command("tail")
sh = Shell.new
sh.transact {
(sh.tail("-n 3") < "/etc/passwd") >> "tail.out"
#(sh.tail("-n 3") < "/etc/passwd") >> ...

絞り込み条件を変える

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

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

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

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

動作例
require 'shell'
Shell.def_system_command("head")
sh = Shell.new
sh.transact {
glob("*.txt").to_a.each { |file|
file.chomp!
cat(file).each { |l|
echo(l) | tee(file + ".tee") >> "al...

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

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

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

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

動作例
require 'shell'
Shell.def_system_command("head")
sh = Shell.new
sh.transact {
glob("*.txt").to_a.each { |file|
file.chomp!
cat(file).each { |l|
echo(l) | tee(file + ".tee") >> "al...

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

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

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

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

動作例
require 'shell'
Shell.def_system_command("head")
sh = Shell.new
sh.transact {
glob("*.txt").to_a.each { |file|
file.chomp!
cat(file).each { |l|
...

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

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

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

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

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

Shell::Filter#to_s -> String (40.0)

実行結果を文字列で返します。

実行結果を文字列で返します。

require 'shell'
Shell.def_system_command("wc")
sh = Shell.new

sh.transact {
puts (cat("/etc/passwd") | wc("-l")).to_s
}

絞り込み条件を変える

Shell::Filter#|(filter) -> object (40.0)

パイプ結合を filter に対して行います。

パイプ結合を filter に対して行います。

@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(...