種類
- インスタンスメソッド (123)
- 文書 (43)
- ライブラリ (11)
ライブラリ
- ビルトイン (33)
- shell (24)
-
shell
/ builtin-command (12) -
shell
/ command-processor (24) -
shell
/ filter (30)
クラス
-
ARGF
. class (11) -
Enumerator
:: Lazy (22) - Shell (24)
-
Shell
:: Cat (6) -
Shell
:: CommandProcessor (24) -
Shell
:: Concat (6) -
Shell
:: Filter (30)
キーワード
-
NEWS for Ruby 2
. 2 . 0 (10) -
collect
_ concat (11) - echo (18)
-
flat
_ map (11) - glob (18)
-
inplace
_ mode (11) -
ruby 1
. 6 feature (11) -
ruby 1
. 8 . 3 feature (11) - tee (18)
- tsort (11)
- 制御構造 (11)
検索結果
先頭5件
-
Shell
:: Cat # each(rs = nil) {|line| . . . } (21101.0) -
@todo
@todo -
Shell
:: Concat # each(rs = nil) {|job| . . . } (21101.0) -
@todo
@todo -
Shell
# cat(*files) -> Shell :: Filter (18125.0) -
実行すると, それらを内容とする Filter オブジェクトを返します.
...ram 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(fi... -
Shell
:: CommandProcessor # cat(*files) -> Shell :: Filter (18125.0) -
実行すると, それらを内容とする Filter オブジェクトを返します.
...ram 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(fi... -
Shell
:: Filter # cat(*files) -> Shell :: Filter (18125.0) -
実行すると, それらを内容とする Filter オブジェクトを返します.
...ram 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(fi... -
Shell
:: Filter # each(rs = nil) -> () (18113.0) -
フィルタの一行ずつをblockに渡します。
...行ずつをblockに渡します。
@param rs レコードセパレーターを表す文字列を指定します。
nil ならば、Shell.record_separatorの値が使用されます。
使用例
require 'shell'
sh = Shell.new
sh.cat("/etc/passwd").each { |line|
puts line
}... -
Enumerator
:: Lazy # collect _ concat {|item| . . . } -> Enumerator :: Lazy (6112.0) -
ブロックの実行結果をひとつに繋げたものに対してイテレートするような Enumerator::Lazy のインスタンスを返します。
...o", "bar"].lazy.flat_map {|i| i.each_char.lazy}.force
#=> ["f", "o", "o", "b", "a", "r"]
//}
ブロックの返した値 x は、以下の場合にのみ分解され、連結されます。
* x が配列であるか、to_ary メソッドを持つとき
* x が each および force メソッド... -
Enumerator
:: Lazy # flat _ map {|item| . . . } -> Enumerator :: Lazy (3012.0) -
ブロックの実行結果をひとつに繋げたものに対してイテレートするような Enumerator::Lazy のインスタンスを返します。
...o", "bar"].lazy.flat_map {|i| i.each_char.lazy}.force
#=> ["f", "o", "o", "b", "a", "r"]
//}
ブロックの返した値 x は、以下の場合にのみ分解され、連結されます。
* x が配列であるか、to_ary メソッドを持つとき
* x が each および force メソッド... -
ruby 1
. 6 feature (102.0) -
ruby 1.6 feature ruby version 1.6 は安定版です。この版での変更はバグ修正がメイン になります。
...2002-03-10 メソッドの戻り値
以下のメソッドの戻り値が正しくなりました。((<ruby-bugs-ja:PR#205>))
* ((<Enumerable/each_with_index>)) が self を返すようになった(以前は nil)
* ((<Process/Process.setpgrp>)) が返す値が不定だった。
* ((<String......返すようになった(以前は false)
* IO#close がクローズ済みな IO に対して IOError を起こすようになった。
* IO#each_byte が self を返すようになった(以前は nil)
: rb_define_module_under()
C 関数 rb_define_module_under() でモジュールを定.......6 の stable-snapshot を使用している方は、2002/1/30
の以下の変更(ChangeLog)
* re.c (rb_reg_search): should set regs.allocated.
で、メモリリークが起こるようになってることに注意してください。
2002/2/13 以降の修正版で直ってま... -
ruby 1
. 8 . 3 feature (72.0) -
ruby 1.8.3 feature *((<ruby 1.8 feature>)) *((<ruby 1.8.2 feature>))
...b] [new]
追加。
: Net::HTTPHeader#each_capitalized [lib] [compat]
: Net::HTTPHeader#each_capitalized_name [lib] [new]
Net::HTTPHeader#canonical_each は Net::HTTPHeader#each_capitalized
に名前が変わりました。canonical_each も each_capitalized の別名とし
て提供......おいて定義されたメソッドを呼び出すことは、$SAFE レベル が 0 のとき
禁止されるようになりました。
$ cat mthd_taint.rb
th = Thread.new{
$SAFE = 3
class Hoge
def foo
puts "safe level: #{$SAFE}"
end
end
}......LE_EVENT#on_event [lib] [bug]
最後に定義したイベントハンドラが有効になるように修正しました。
=== 2005-07-27
: Dir#each [ruby] [bug]
: Dir#entries [ruby] [bug]
1回メソッドを呼んでしまうと空になるバグを修正しました。
$ ruby-1.8.2... -
tsort (60.0)
-
tsort はトポロジカルソートと強連結成分に関するモジュールを提供します。
...を提供します。
=== Example
//emlist[][ruby]{
require 'tsort'
class Hash
include TSort
alias tsort_each_node each_key
def tsort_each_child(node, &block)
fetch(node).each(&block)
end
end
{1=>[2, 3], 2=>[3], 3=>[], 4=>[]}.tsort
#=> [3, 2, 1, 4]
{1=>[2], 2=>[3, 4], 3=>[2], 4=>[]}......ult = []
end
def rule(outputs, inputs=[], &block)
triple = [outputs, inputs, block]
outputs.each {|f| @dep[f] = [triple]}
@dep[triple] = inputs
end
def build(target)
each_strongly_connected_component_from(target) {|ns|
if ns.length != 1
fs = ns.delete_if {|n|......ck)
@dep[node].each(&block)
end
include TSort
end
def command(arg)
print arg, "\n"
system arg
end
m = Make.new
m.rule(%w[t1]) { command 'date > t1' }
m.rule(%w[t2]) { command 'date > t2' }
m.rule(%w[t3]) { command 'date > t3' }
m.rule(%w[t4], %w[t1 t3]) { command 'cat t1 t3 > t4' }
m.r... -
制御構造 (36.0)
-
制御構造 条件分岐: * if * unless * case 繰り返し: * while * until * for * break * next * redo * retry 例外処理: * raise * begin その他: * return * BEGIN * END
...ブジェクトの各要素に対して本体を繰り返し
て実行します。これは以下の式とほぼ等価です。
(式1).each `{' `|' lhs..`|' 式2.. `}'
「ほぼ」というのは、do ... endまたは{ }による
ブロックは新しいローカル変数の有効範......たオブジェクトの each
メソッドの戻り値を返します。
複数のループ変数指定は以下のような場合に使用します。
//emlist[例][ruby]{
for i,j in [[1,2], [3,4], [5,6]]
p [i,j]
end
# => [1, 2]
# [3, 4]
# [5, 6]
//}
for や each で配列要素を複数......数を指定した場合はループの戻り値はその引数になります。
====[a:next] next
//emlist[例][ruby]{
# 空行を捨てるcat
ARGF.each_line do |line|
next if line.strip.empty?
print line
end
//}
文法:
next
next val
nextはもっとも内側のル...