種類
- インスタンスメソッド (129)
- モジュール関数 (48)
- 文書 (24)
- クラス (12)
- ライブラリ (12)
ライブラリ
- ビルトイン (105)
- shell (24)
-
shell
/ command-processor (24) -
shell
/ filter (24) - socket (12)
クラス
-
ARGF
. class (24) - Array (21)
- Shell (24)
-
Shell
:: CommandProcessor (24) -
Shell
:: Filter (24) - String (12)
モジュール
- Kernel (48)
キーワード
- TCPServer (12)
- cat (18)
-
each
_ char (12) -
each
_ codepoint (12) - glob (18)
- irb (12)
- pack (21)
- pack テンプレート文字列 (12)
-
ruby 1
. 6 feature (12) - spawn (48)
- tee (18)
- unpack (12)
検索結果
先頭5件
-
Shell
# echo(*strings) -> Shell :: Filter (18119.0) -
実行すると, それらを内容とする Filter オブジェクトを返します.
...ings シェルコマンド 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")... -
Shell
:: CommandProcessor # echo(*strings) -> Shell :: Filter (18119.0) -
実行すると, それらを内容とする Filter オブジェクトを返します.
...ings シェルコマンド 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")... -
Shell
:: Filter # echo(*strings) -> Shell :: Filter (18119.0) -
実行すると, それらを内容とする Filter オブジェクトを返します.
...ings シェルコマンド 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")... -
ARGF
. class # each _ char -> Enumerator (112.0) -
レシーバに含まれる文字を一文字ずつブロックに渡して評価します。
...えられなかった場合は、Enumerator オブジェクトを生成し
て返します。
例:
# $ echo "line1\n" > test1.txt
# $ echo "line2\n" > test2.txt
# $ ruby test.rb test1.txt test2.txt
# test.rb
ARGF.each_char # => #<Enumerator: ARGF:each_char>
ARGF.each_char{|e|p... -
ARGF
. class # each _ codepoint -> Enumerator (112.0) -
self の各コードポイントに対して繰り返しブロックを呼びだします。
...ブロックを省略した場合には、Enumerator を返します。
例:
# $ echo "line1\n" > test1.txt
# $ echo "line2\n" > test2.txt
# $ ruby test.rb test1.txt test2.txt
# test.rb
ARGF.each_codepoint # => #<Enumerator: ARGF:each_codepoint>
ARGF.each_codepoint{|e|... -
ruby 1
. 6 feature (66.0) -
ruby 1.6 feature ruby version 1.6 は安定版です。この版での変更はバグ修正がメイン になります。
...返していた
p "foo".slice!(5,10)
=> ruby 1.6.7 (2002-03-01) [i586-linux]
nil
-:2:in `slice!': index 5 out of string (IndexError)
from -:2
=> ruby 1.6.7 (2002-08-01) [i586-linux]
nil
nil
: 2002-07-05 String#spli......前までは $; が有効にな
るのは引数省略時だけでした。
$; = ":"
p "a:b:c".split(nil)
=> -:2:in `split': bad separator (ArgumentError)
from -:2
ruby 1.6.7 (2002-03-01) [i586-linux]
=> ruby 1.6.7 (2002-07-30) [i586-linux]
["a", "b", "c"......した。((<ruby-dev:13756>))
$ echo p __FILE__ > ~/a.rb
$ ruby17 -v -r~/a -e0
ruby 1.7.1 (2001-07-03) [i686-linux]
0: No such file to load -- ~/a (LoadError)
$ ruby16 -v -r~/a -e0
ruby 1.6.4 (2001-07-02) [i686-linux]
0: No such file to load -- ~/a (LoadError)
$ ruby... -
irb (48.0)
-
irb は Interactive Ruby の略です。 irb を使うと、Ruby の式を標準入力から簡単に入力・実行することができます。
...する行を表示する
--noverbose これから実行する行を表示しない (デフォルト)
--echo 実行結果を表示する (デフォルト)
--noecho 実行結果を表示しない
--inspect 結果出力にinspectを用いる (bc モード以外......を指定したのと同じ効果が得られます。
IRB.conf[:AUTO_INDENT] = false
IRB.conf[:BACK_TRACE_LIMIT] = 16
IRB.conf[:DEBUG_LEVEL] = 1
IRB.conf[:ECHO] = nil
IRB.conf[:EVAL_HISTORY] = nil
IRB.conf[:HISTORY_FILE] = nil
IRB.conf[:IGNORE_EOF] = true
IRB.conf[:IGNORE_SIGINT] =......= false
IRB.conf[:SAVE_HISTORY] = nil
IRB.conf[:USE_LOADER] = true
IRB.conf[:USE_READLINE] = nil
IRB.conf[:USE_TRACER] = true
IRB.conf[:VERBOSE] = true
それぞれの設定値の詳細については、IRB::Context を参照してください。
====[a:customize_prompt] プロンプト......する行を表示する
--noverbose これから実行する行を表示しない (デフォルト)
--echo 実行結果を表示する (デフォルト)
--noecho 実行結果を表示しない
--inspect 結果出力にinspectを用いる
--noinspect......= false
IRB.conf[:SAVE_HISTORY] = 1000
IRB.conf[:USE_LOADER] = true
IRB.conf[:USE_READLINE] = nil
IRB.conf[:USE_TRACER] = true
IRB.conf[:VERBOSE] = true
それぞれの設定値の詳細については、IRB::Context を参照してください。
====[a:customize_prompt] プロンプト... -
Kernel
. # spawn(env , program , *args , options={}) -> Integer (24.0) -
引数を外部コマンドとして実行しますが、生成した 子プロセスの終了を待ち合わせません。生成した子プロセスのプロセスIDを返します。
...数のファイルデスクリプタを合わせてリダイレクトするには、
[ :child, FileDescriptor ] を使うこともできます。
これは子プロセス側で FileDescriptor にリダイレクトすることを意味します。
これはファイルデスクリプタを直接指......IO.popen で、子プロセスの
stderr と stdout を混ぜる例を以下に示します。
//emlist[][ruby]{
io = IO.popen(["sh", "-c", "echo out; echo err >&2", :err=>[:child, :out]])
p io.read #=> "out\nerr\n
//}
spawn と IO.popen では
デフォルトでは非標準的なファイルデス......=>false) # don't close 3,4,5,...
//}
これを利用して spawn を IO.popen のように使うことができます。
//emlist[][ruby]{
# similar to r = IO.popen(command)
r, w = IO.pipe
pid = spawn(command, :out=>w) # r は子プロセスで閉じられる
w.close
//}
「:close」を使って......don't close 3,4,5,... (default)
//}
これを利用して spawn を IO.popen のように使うことができます。
//emlist[][ruby]{
# similar to r = IO.popen(command)
r, w = IO.pipe
pid = spawn(command, :out=>w) # r は子プロセスで閉じられる
w.close
//}
「:close」を使って... -
Kernel
. # spawn(program , *args) -> Integer (24.0) -
引数を外部コマンドとして実行しますが、生成した 子プロセスの終了を待ち合わせません。生成した子プロセスのプロセスIDを返します。
...数のファイルデスクリプタを合わせてリダイレクトするには、
[ :child, FileDescriptor ] を使うこともできます。
これは子プロセス側で FileDescriptor にリダイレクトすることを意味します。
これはファイルデスクリプタを直接指......IO.popen で、子プロセスの
stderr と stdout を混ぜる例を以下に示します。
//emlist[][ruby]{
io = IO.popen(["sh", "-c", "echo out; echo err >&2", :err=>[:child, :out]])
p io.read #=> "out\nerr\n
//}
spawn と IO.popen では
デフォルトでは非標準的なファイルデス......=>false) # don't close 3,4,5,...
//}
これを利用して spawn を IO.popen のように使うことができます。
//emlist[][ruby]{
# similar to r = IO.popen(command)
r, w = IO.pipe
pid = spawn(command, :out=>w) # r は子プロセスで閉じられる
w.close
//}
「:close」を使って......don't close 3,4,5,... (default)
//}
これを利用して spawn を IO.popen のように使うことができます。
//emlist[][ruby]{
# similar to r = IO.popen(command)
r, w = IO.pipe
pid = spawn(command, :out=>w) # r は子プロセスで閉じられる
w.close
//}
「:close」を使って... -
Array
# pack(template) -> String (12.0) -
配列の内容を template で指定された文字列にしたがって、 バイナリとしてパックした文字列を返します。
...0\x00\x00\x00\x00\x00"
["abc"].pack("P3") # => "\xA0\xEE\er\x84U\x00\x00"
["abc"].pack("P4") # => ArgumentError: too short buffer for P(3 for 4)
[""].pack("P") # => ArgumentError: too short buffer for P(0 for 1)
//}
: u
uuencodeされた文字列
//emlist[][ruby]{
[""].pack("u") #......ffffff].pack("U") # => "\xFD\xBF\xBF\xBF\xBF\xBF"
[0x80000000].pack("U") # => RangeError: pack(U): value out of range
[0,256,65536].pack("U3").b # => "\x00\xC4\x80\xF0\x90\x80\x80"
"\x00\xC4\x80\xF0\x90\x80\x80".unpack("U3") # => [0, 256, 6......ck("C4").join(".")
# => "127.0.0.1"
"127.0.0.1".split(".").collect {|c| c.to_i}.pack("C4")
# => "\x7F\x00\x00\x01"
//}
: sockaddr_in 構造体
//emlist[][ruby]{
require 'socket'
[Socket::AF_INET,
Socket.getservbyname('echo'),
127, 0, 0, 1].pack("s n C4 x8")
# => "\x02\x00\x00\a\x7F\x00\x00\x01\x...