るりまサーチ

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

別のキーワード

  1. kernel system
  2. _builtin system
  3. socket pf_system
  4. socket af_system
  5. socket eai_system

検索結果

<< 1 2 3 > >>

Shell.def_system_command(command, path = command) -> nil (6131.0)

Shell のメソッドとして command を登録します.

...ドを実行するにはまず, Shellのメソッドとして定義します.
注) コマンドを定義しなくとも直接実行できる Shell#system コマンドもあります.

@param command Shell のメソッドとして定義するコマンドを文字列で指定します。

@param path...
...require 'shell'
Shell.def_system_command "ls"
# ls を定義

Shell.def_system_command "sys_sort", "sort"
# sortコマンドをsys_sortとして定義

sh = Shell.new
sh.transact {
ls.each { |l|
puts
l
}
(ls("-l") | sys_sort("-k 5")).each {|l|
puts
l
}
}...

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

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

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

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

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

require '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 (6125.0)

commandを削除します.

...指定します。

動作例:
require '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
}
}
rescue NameError => err
puts
err
end...

ruby 1.8.4 feature (78.0)

ruby 1.8.4 feature ruby 1.8.4 での ruby 1.8.3 からの変更点です。

...ns invalid symbol representations:

puts
:"!".inspect
puts
:"=".inspect
puts
:"0".inspect
puts
:"$1".inspect
puts
:"@1".inspect
puts
:"@@1".inspect
puts
:"@".inspect
puts
:"@@".inspect

# => r...
..."
:"@"
:"@@"

3) Symbol#inspect sometimes returns suboptimal symbol representations:
puts
:foo!.inspect
puts
:bar?.inspect

# => ruby 1.8.3 (2005-09-21) [i686-linux]
:"foo!"
:"bar?"...
...i Nakada <nobu@ruby-lang.org>
#
# * file.c (test_identical): test if two files are identical.
#
# * file.c (rb_f_test): support DOSISH systems where st_ino is not
# reliable. fixed: [ruby-core:06672]
#
# * win32.h, win32.c (rb_w32_osid): check the running platform.

i...

Timeout.#timeout(sec, exception_class = nil) {|i| ... } -> object (48.0)

ブロックを sec 秒の期限付きで実行します。 ブロックの実行時間が制限を過ぎたときは例外 Timeout::Error が発生します。

...min[0] += 1 : min[1] += 1
end
end

t = 5
min = [ 0, 0]
begin
Timeout.timeout(t){
calc_pi(min)
}
rescue Timeout::Error
puts
"timeout"
end

printf "%d: pi = %f\n", min[0] + min[1], min[0]*4.0/(min[0]+min[1])
#例
#=> 417519: pi = 3.141443

例 独自の例外...
...quire 'timeout'

class MYError < Exception;end
begin
Timeout.timeout(5, MYError) {
sleep(30)
}
rescue MYError => err
puts
"MYError"
puts
err
end

=== 注意

timeout による割り込みは Thread によって実現されています。
C 言語レベルで実装され...
...発生しないので
# その場合は、t に小さい数値(0.000001のような)に変える。


timeout による割り込みは Kernel.#system によって呼び出された外部プログラムを
タイムアウトさせる事はできないので、IO.popen、Kernel.#openを使用する...

絞り込み条件を変える

Timeout.#timeout(sec, exception_class, message) {|i| ... } -> object (48.0)

ブロックを sec 秒の期限付きで実行します。 ブロックの実行時間が制限を過ぎたときは例外 Timeout::Error が発生します。

...min[0] += 1 : min[1] += 1
end
end

t = 5
min = [ 0, 0]
begin
Timeout.timeout(t){
calc_pi(min)
}
rescue Timeout::Error
puts
"timeout"
end

printf "%d: pi = %f\n", min[0] + min[1], min[0]*4.0/(min[0]+min[1])
#例
#=> 417519: pi = 3.141443

例 独自の例外...
...quire 'timeout'

class MYError < Exception;end
begin
Timeout.timeout(5, MYError) {
sleep(30)
}
rescue MYError => err
puts
"MYError"
puts
err
end

=== 注意

timeout による割り込みは Thread によって実現されています。
C 言語レベルで実装され...
...発生しないので
# その場合は、t に小さい数値(0.000001のような)に変える。


timeout による割り込みは Kernel.#system によって呼び出された外部プログラムを
タイムアウトさせる事はできないので、IO.popen、Kernel.#openを使用する...

Rubyで使われる記号の意味(正規表現の複雑な記号は除く) (42.0)

Rubyで使われる記号の意味(正規表現の複雑な記号は除く) ex q num per and or  plus minus ast slash hat sq  period comma langl rangl eq tilde  dollar at under lbrarbra  lbra2rbra2 lbra3rbra3 dq colon ac  backslash semicolon

...列で %Q!STRING! と同じ。
//emlist{
p %!nomad! #=> "nomad"
//}

: % ruby -e "puts 'Hello'"

コマンドラインへの入力を示す。rubyスクリプト上で入力を行うには `command` や system(command) などと書く

===[a:and] &

: xxx & yyy

論理積演算子。または...
...たは def -@

単項演算子 +X や -X を定義するときの表記法。
//emlist{
class Symbol
def +@
self.upcase
end
end

puts
(+:joke) #=> JOKE
//}

===[a:under] _

: xxx_yyy

識別子の中では小文字と同じ扱い

: 123_456

文字コード以外の数値リテ...
...//emlist{
puts
`ruby -h`
#=> Usage: ruby [switches] [--] [programfile] [arguments]
#=> ....
//}

===[a:backslash] \
バックスラッシュ。環境によって¥に見えたりします。

: puts "abc\"def"

文字列や正規表現の中のエスケープ。
//emlist{
puts
"abc\"de...

WIN32OLE_TYPELIB.new(libname, mjv = nil, miv = nil) -> WIN32OLE_TYPELIB (36.0)

WIN32OLE_TYPELIBオブジェクトを生成します。

...DOWS\\SYSTEM32\\SHELL32.DLL")
puts
tlib1.name # => 'Microsoft Excel 14.0 Object Library'
puts
tlib2.name # => 'Microsoft Excel 14.0 Object Library'
puts
tlib3.name # => 'Microsoft Excel 14.0 Object Library'
puts
tlib4.name # => 'Microsoft Excel 14.0 Object Library'
puts
tlib5...

Shell.alias_command(alias, command, *opts) {...} -> self (34.0)

コマンドの別名(エイリアス)を作成します。 コマンドが無い場合は、Shell.def_system_command などであらかじめ作成します.

...コマンドの別名(エイリアス)を作成します。
コマンドが無い場合は、Shell.def_system_command などであらかじめ作成します.

@param alias エイリアスの名前を文字列で指定します.

@param command コマンド名を文字列で指定します.

@param...
...を指定します.

使用例: ls -la | sort -k 5 のような例。

require 'shell'
Shell.def_system_command("ls")
Shell.alias_command("lsla", "ls", "-a", "-l")
Shell.def_system_command("sort")
sh = Shell.new
sh.transact {
(lsla | sort("-k 5")).each {|l|
puts
l
}
}...

Kernel.#`(command) -> String (24.0)

command を外部コマンドとして実行し、その標準出力を文字列として 返します。このメソッドは `command` の形式で呼ばれます。

...得るには、$? を参照します。

コマンドの出力を得る必要がなく、単にコマンドを実行したいだけなら
Kernel.#system を使います。特に端末を制御するコマンドでは
`command` は失敗するかもしれません。

d:spec/literal#command も参照...
...Errno::EXXX コマンドを実行できないときや失敗した場合に発生します。

//emlist[例][ruby]{
puts
`ruby -v` #=> ruby 1.8.6 (2007-03-13 patchlevel 0) [i386-mswin32]
puts
$?.inspect #=> #<Process::Status: pid=3580,exited(0)>
//}

@see Kernel.#system,Kernel.#exec,Kernel.#spawn...

絞り込み条件を変える

NEWS for Ruby 2.0.0 (24.0)

NEWS for Ruby 2.0.0 このドキュメントは前回リリース以降のバグ修正を除くユーザーに影響のある機能の変更のリストです。

...対パ スで返します。
* 追加: Kernel.#caller_locations フレーム情報の配列を返します
* 拡張: Kernel.#warn Kernel.#puts のように複数の引数を受け付けるようになりました
* 拡張: Kernel.#caller 第2引数で取得するスタックのサイズ...
...: Object#to_enum Object#enum_for サイズの遅延評価のためにブロックを受け取るようになりました
* 非互換: Kernel.#system, Kernel.#exec は非標準のファイルディスクリプタを閉じます
:close_others オプションのデフォルト値を true に...
...close_others option is true by default for system() and exec().
Also, the close-on-exec flag is set by default for all new file descriptors.
This means file descriptors doesn't inherit to spawned process unless
explicitly requested such as system(..., fd=>fd).

* Kernel#respond_to? aga...
<< 1 2 3 > >>