36件ヒット
[1-36件を表示]
(0.084秒)
ライブラリ
- ビルトイン (12)
- optparse (12)
- shell (6)
-
shell
/ filter (6)
クラス
- OptionParser (12)
- Shell (6)
-
Shell
:: Filter (6)
モジュール
- Enumerable (12)
キーワード
- chunk (12)
- each (6)
-
record
_ separator (6)
検索結果
先頭4件
-
OptionParser
# separator(sep) -> () (18226.0) -
サマリにオプションを区切るための文字列 sep を挿入します。 オプションにいくつかの種類がある場合に、サマリがわかりやすくなります。
...= OptionParser.new
opts.banner = "Usage: example.rb [options]"
opts.separator ""
opts.separator "Specific options:"
opts.on("-r", "--require LIBRARY") do |lib|
options.library << lib
end
opts.separator ""
opts.separator "Common options:"
opts.on_tail("-h", "--help", "Show this message")... -
Shell
# record _ separator -> String (6202.0) -
@todo
@todo -
Enumerable
# chunk {|elt| . . . } -> Enumerator (113.0) -
要素を前から順にブロックで評価し、その結果によって 要素をチャンクに分けた(グループ化した)要素を持つ Enumerator を返します。
...のがわかるでしょう。
//emlist[例][ruby]{
[3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5].chunk {|n|
n.even?
}.each {|even, ary|
p [even, ary]
}
# => [false, [3, 1]]
# [true, [4]]
# [false, [1, 5, 9]]
# [true, [2, 6]]
# [false, [5, 3, 5]]
//}
このメソッドは各要素が既にソ......h {|ch, lines| p [ch, lines.length] }
}
# => ["A", 17096]
# ["B", 11070]
# ["C", 19901]
# ["D", 10896]
# ...
//}
さらにこのメソッドは以下の値を特別扱いします。
* ブロックの評価値が nil もしくは :_separator であった場合、
その要素を....../emlist[例][ruby]{
[1, 2].chunk { |item| :_underscore }.to_a
# => RuntimeError: symbols beginning with an underscore are reserved
# 「.to_a」無しだと Enumerator を返すのみで例外は発生しない
//}
nil、 :_separator はある要素を無視したい場合に用います。
例と... -
Shell
:: Filter # each(rs = nil) -> () (107.0) -
フィルタの一行ずつをblockに渡します。
...行ずつをblockに渡します。
@param rs レコードセパレーターを表す文字列を指定します。
nil ならば、Shell.record_separatorの値が使用されます。
使用例
require 'shell'
sh = Shell.new
sh.cat("/etc/passwd").each { |line|
puts line
}...