種類
- 文書 (22)
- インスタンスメソッド (17)
- 特異メソッド (11)
ライブラリ
- csv (11)
- optparse (11)
-
shell
/ filter (6)
クラス
- CSV (11)
- OptionParser (11)
-
Shell
:: Filter (6)
キーワード
- each (6)
-
ruby 1
. 6 feature (11) - 正規表現 (11)
検索結果
先頭5件
-
ruby 1
. 6 feature (23318.0) -
ruby 1.6 feature ruby version 1.6 は安定版です。この版での変更はバグ修正がメイン になります。
...00019>))
: 2002-09-11: Queue#((<Queue/pop>))
Queue#pop に競合状態の問題がありました ((<ruby-dev:17223>))
: 2002-09-11: SizedQueue.new
引数に 0 以下を受けつけるバグが修正されました。
: 2002-09-05: ((<リテラル/式展開>))
stable snapshot で、一......フォルト値 (((<Hash/default>))) も == で等しい
ときに等しいとみなされるようになりました。
p Hash.new("foo") == Hash.new("bar")
=> ruby 1.6.7 (2002-03-01) [i586-linux]
true
=> ruby 1.6.7 (2002-08-21) [i586-linux]
false......以前までは $; が有効にな
るのは引数省略時だけでした。
$; = ":"
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",... -
CSV
. new(data , options = Hash . new) -> CSV (18220.0) -
このメソッドは CSV ファイルを読み込んだり、書き出したりするために String か IO のインスタンスをラップします。
...und, +data+ is ARGF, Object::STDIN, Object::STDOUT, or
Object::STDERR, or the stream is only available for output, the default
$INPUT_RECORD_SEPARATOR ($/) is used. Obviously,
discovery takes a little time. Set manually if speed is important. Also
note that IO objects should be opened......e
1,taro,tanaka,20
2,jiro,suzuki,18
3,ami,sato,19
4,yumi,adachi,21
EOS
File.write("test.csv", users)
File.open("test.csv", "r") do |f|
csv = CSV.new(f, headers: true)
csv.class # => CSV
csv.first # => #<CSV::Row "id":"1" "first name":"taro" "last name":"tanaka" "age":"20">
end
//}
//emlist[......み][ruby]{
require "csv"
users =<<-EOS
id|first name|last name|age
1|taro|tanaka|20
2|jiro|suzuki|18
3|ami|sato|19
4|yumi|adachi|21
EOS
csv = CSV.new(users, headers: true, col_sep: "|")
p csv.class # => CSV
p csv.first # => #<CSV::Row "id":"1" "first name":"taro" "last name":"tanaka" "age":"20">... -
OptionParser
# separator(sep) -> () (18131.0) -
サマリにオプションを区切るための文字列 sep を挿入します。 オプションにいくつかの種類がある場合に、サマリがわかりやすくなります。
...y]{
require 'optparse'
opts = 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", "--... -
正規表現 (72.0)
-
正規表現 * metachar * expansion * char * anychar * string * str * quantifier * capture * grouping * subexp * selector * anchor * cond * option * encoding * comment * free_format_mode * absenceop * list * specialvar * references
...列中のどの場所であるかを知ることができます。
//emlist[][ruby]{
/pat/
%r{pat}
//}
などの正規表現リテラルや Regexp.new などで正規表現
オブジェクトを得ることができます。
===[a:metachar] メタ文字列とリテラル、メタ文字とエス......\t 水平タブ horizontal tab (0x09)
\v 垂直タブ vertical tab (0x0B)
\n 改行 newline (0x0A)
\r 復帰 return (0x0D)
\b バックスペース back space (0x08......al_Number)
* [:alpha:] 英字 (Letter | Mark)
* [:ascii:] ASCIIに含まれる文字 (0000 - 007F)
* [:blank:] スペースとタブ (Space_Separator | 0009)
* [:cntrl:] 制御文字 (Control | Format | Unassigned | Private_Use | Surrogate)
* [:digit:] 数字 (Decimal_Number)
* [:graph:]... -
Shell
:: Filter # each(rs = nil) -> () (12.0) -
フィルタの一行ずつをblockに渡します。
...行ずつをblockに渡します。
@param rs レコードセパレーターを表す文字列を指定します。
nil ならば、Shell.record_separatorの値が使用されます。
使用例
require 'shell'
sh = Shell.new
sh.cat("/etc/passwd").each { |line|
puts line
}...