ライブラリ
- English (117)
- ビルトイン (155)
- csv (13)
- drb (13)
- fileutils (13)
- pathname (39)
- rake (130)
-
rake
/ loaders / makefile (13) -
rake
/ packagetask (208)
クラス
- Array (52)
- NameError (11)
- Object (13)
- Pathname (39)
- Proc (13)
-
Rake
:: Application (13) -
Rake
:: FileList (13) -
Rake
:: MakefileLoader (13) -
Rake
:: NameSpace (13) -
Rake
:: PackageTask (208) - Random (39)
モジュール
- FileUtils (13)
- Kernel (131)
- ObjectSpace (13)
-
Rake
:: TaskManager (39) - RakeFileUtils (52)
キーワード
-
$ ARGV (13) -
$ DEFAULT _ INPUT (13) -
$ ERROR _ INFO (13) -
$ ERROR _ POSITION (13) -
$ INPUT _ LINE _ NUMBER (13) -
$ LAST _ PAREN _ MATCH (13) -
$ NR (13) -
$ ORS (13) -
$ OUTPUT _ RECORD _ SEPARATOR (13) -
1
. 6 . 8から1 . 8 . 0への変更点(まとめ) (13) - CSV (13)
- DRbProtocol (13)
-
NEWS for Ruby 2
. 0 . 0 (13) -
NEWS for Ruby 2
. 3 . 0 (11) - abort (14)
-
add
_ loader (13) -
bigdecimal
/ ludcmp (13) -
bigdecimal
/ newton (13) - binding (13)
-
cgi
/ session (13) -
cp
_ r (13) - delete (13)
- egrep (13)
- find (13)
-
in
_ namespace (13) - intern (13)
- irb (13)
- load (13)
- logger (13)
- name (13)
- name= (13)
-
need
_ tar (13) -
need
_ tar= (13) -
need
_ tar _ bz2 (13) -
need
_ tar _ bz2= (13) -
need
_ tar _ gz (13) -
need
_ tar _ gz= (13) -
need
_ zip (13) -
need
_ zip= (13) - new (26)
-
nowrite
_ flag (13) -
nowrite
_ flag= (13) - optparse (13)
-
package
_ dir (13) -
package
_ dir= (13) -
package
_ dir _ path (13) -
package
_ files (13) -
package
_ files= (13) - profile (6)
- rand (39)
- receiver (11)
-
respond
_ to _ missing? (13) -
rinda
/ rinda (13) - rss (13)
-
ruby 1
. 8 . 4 feature (13) - split (13)
-
synthesize
_ file _ task (13) -
undefine
_ finalizer (13) - unlink (13)
-
verbose
_ flag (13) -
verbose
_ flag= (13) - xmlrpc (3)
検索結果
先頭5件
-
Array
# sample -> object | nil (18128.0) -
配列の要素を1個(引数を指定した場合は自身の要素数を越えない範囲で n 個) ランダムに選んで返します。
..._a
p a.sample #=> 9
p a.sample #=> 10
p a.sample(3) #=> [1, 9, 3]
p a #=> [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
//}
random SecureRandom などの乱数生成器を渡すことができます。
//emlist[例][ruby]{
require 'securerandom'
a = (1..10).to_a
p a.sample(rando... -
Array
# sample(n) -> Array (18128.0) -
配列の要素を1個(引数を指定した場合は自身の要素数を越えない範囲で n 個) ランダムに選んで返します。
..._a
p a.sample #=> 9
p a.sample #=> 10
p a.sample(3) #=> [1, 9, 3]
p a #=> [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
//}
random SecureRandom などの乱数生成器を渡すことができます。
//emlist[例][ruby]{
require 'securerandom'
a = (1..10).to_a
p a.sample(rando... -
Array
# sample(n , random: Random) -> Array (18128.0) -
配列の要素を1個(引数を指定した場合は自身の要素数を越えない範囲で n 個) ランダムに選んで返します。
..._a
p a.sample #=> 9
p a.sample #=> 10
p a.sample(3) #=> [1, 9, 3]
p a #=> [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
//}
random SecureRandom などの乱数生成器を渡すことができます。
//emlist[例][ruby]{
require 'securerandom'
a = (1..10).to_a
p a.sample(rando... -
Array
# sample(random: Random) -> object | nil (18128.0) -
配列の要素を1個(引数を指定した場合は自身の要素数を越えない範囲で n 個) ランダムに選んで返します。
..._a
p a.sample #=> 9
p a.sample #=> 10
p a.sample(3) #=> [1, 9, 3]
p a #=> [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
//}
random SecureRandom などの乱数生成器を渡すことができます。
//emlist[例][ruby]{
require 'securerandom'
a = (1..10).to_a
p a.sample(rando... -
optparse (192.0)
-
コマンドラインのオプションを取り扱うためのライブラリです。
...b を受け付けるコマンドを作成する例です。
//emlist[sample.rb][ruby]{
require 'optparse'
opt = OptionParser.new
opt.on('-a') {|v| p v }
opt.on('-b') {|v| p v }
opt.parse!(ARGV)
p ARGV
//}
↓
ruby sample.rb -a foo bar -b baz
# => true
true......)。ただし、環境変数 POSIXLY_CORRECT が定義してあると
この挙動は変更されます。
env POSIXLY_CORRECT=1 ruby ./sample.rb -a foo bar -b baz
# => true # -a はオプションと解釈
["foo", "bar", "-b", "baz"]......ser#parse! では、ARGV からオプションが取り除かれます。
これを避けるには OptionParser#parse を使います。
//emlist[sample.rb][ruby]{
require 'optparse'
opt = OptionParser.new
opt.on('-a') {|v| p v }
opt.on('-b') {|v| p v }
# parse() の場合、ARGVは変更され... -
rss (126.0)
-
RSS を扱うためのライブラリです。
...],
]
全てのキーは省略可能です.
例えば,xml-stylesheetとしてsample.xslを指定する場合は以下の
ようにします.
rss.xml_stylesheets << RSS::XMLStyleSheet.new({:href="/?originalUrl=https%3A%2F%2Frurema.clear-code.com%2F%26gt%3B%2520%26quot%3B%253Cspan%2520class%3D"keyword">sample.xsl"})
本当は{:type => "text/xsl"}も指定しないといけないとこ
ろ......nnel.description = "Example Site"
maker.channel.link = "http://example.com/"
end
もし,
* http://example.com/article.htmlにある
* Sample Articleというタイトルの
エントリを含めたければ以下のようにします.
require "rss"
rss = RSS::Maker.make("1.0")......maker.channel.link = "http://example.com/"
item = maker.items.new_item
item.link = "http://example.com/article.html"
item.title = "Sample Article"
end
===== 更新時刻を追加
もし,先のエントリが
* 2004/11/1 10:10
のものならこうします.
require "rs... -
Object
# respond _ to _ missing?(symbol , include _ private) -> bool (60.0) -
自身が symbol で表されるメソッドに対し BasicObject#method_missing で反応するつもりならば真を返します。
...class Sample
def method_missing(name, *args)
if name =~ /^to_*/
[name, *args] # => [:to_sample, "sample args1", "sample args2"]
return
else
super
end
end
def respond_to_missing?(sym, include_private)
(sym =~ /^to_*/) ? true : super
end
end
s = Sample.new......s.to_sample("sample args1", "sample args2")
s.respond_to?(:to_sample) # => true
s.respond_to?(:sample) # => false
//}
@see Object#respond_to?, BasicObject#method_missing... -
Rake
:: FileList # egrep(pattern) {|filename , count , line| . . . } (60.0) -
与えられたパターンをファイルリストから grep のように検索します。
...emlist[][ruby]{
# Rakefile での記載例とする
IO.write("sample1", "line1\nline2\nline3\n")
IO.write("sample2", "line1\nline2\nline3\nline4\n")
task default: :test_rake_app
task :test_rake_app do
file_list = FileList.new('sample*')
file_list.egrep(/line/) # => 7
file_list.egrep(/.*/)......=> "filename = sample1, count = 1, line = line1\n"
# => "filename = sample1, count = 2, line = line2\n"
# => "filename = sample1, count = 3, line = line3\n"
# => "filename = sample2, count = 1, line = line1\n"
# => "filename = sample2, count = 2, line = line2\n"
# => "filename = sample2, count = 3,......line = line3\n"
# => "filename = sample2, count = 4, line = line4\n"
//}...
