ライブラリ
- English (108)
- ビルトイン (142)
- csv (12)
- drb (12)
- fileutils (12)
- pathname (36)
- rake (120)
-
rake
/ loaders / makefile (12) -
rake
/ packagetask (192)
クラス
- Array (48)
- NameError (10)
- Object (12)
- Pathname (36)
- Proc (12)
-
Rake
:: Application (12) -
Rake
:: FileList (12) -
Rake
:: MakefileLoader (12) -
Rake
:: NameSpace (12) -
Rake
:: PackageTask (192) - Random (36)
モジュール
- FileUtils (12)
- Kernel (120)
- ObjectSpace (12)
-
Rake
:: TaskManager (36) - RakeFileUtils (48)
キーワード
-
$ ARGV (12) -
$ DEFAULT _ INPUT (12) -
$ ERROR _ INFO (12) -
$ ERROR _ POSITION (12) -
$ INPUT _ LINE _ NUMBER (12) -
$ LAST _ PAREN _ MATCH (12) -
$ NR (12) -
$ ORS (12) -
$ OUTPUT _ RECORD _ SEPARATOR (12) -
1
. 6 . 8から1 . 8 . 0への変更点(まとめ) (12) - CSV (12)
- DRbProtocol (12)
-
NEWS for Ruby 2
. 0 . 0 (12) -
NEWS for Ruby 2
. 3 . 0 (10) - abort (12)
-
add
_ loader (12) -
bigdecimal
/ ludcmp (12) -
bigdecimal
/ newton (12) - binding (12)
-
cgi
/ session (12) -
cp
_ r (12) - delete (12)
- egrep (12)
- find (12)
-
in
_ namespace (12) - intern (12)
- irb (12)
- load (12)
- logger (12)
- name (12)
- name= (12)
-
need
_ tar (12) -
need
_ tar= (12) -
need
_ tar _ bz2 (12) -
need
_ tar _ bz2= (12) -
need
_ tar _ gz (12) -
need
_ tar _ gz= (12) -
need
_ zip (12) -
need
_ zip= (12) - new (24)
-
nowrite
_ flag (12) -
nowrite
_ flag= (12) - optparse (12)
-
package
_ dir (12) -
package
_ dir= (12) -
package
_ dir _ path (12) -
package
_ files (12) -
package
_ files= (12) - profile (6)
- rand (36)
- receiver (10)
-
respond
_ to _ missing? (12) -
rinda
/ rinda (12) - rss (12)
-
ruby 1
. 8 . 4 feature (12) - split (12)
-
synthesize
_ file _ task (12) -
undefine
_ finalizer (12) - unlink (12)
-
verbose
_ flag (12) -
verbose
_ flag= (12) - 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 => "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"
//}... -
ObjectSpace
. # undefine _ finalizer(obj) -> object (36.0) -
obj に対するファイナライザをすべて解除します。 obj を返します。
...][ruby]{
class Sample
def Sample.callback
proc {
puts "finalize"
}
end
def initialize
ObjectSpace.define_finalizer(self, Sample.callback)
end
def undef
ObjectSpace.undefine_finalizer(self)
end
end
Sample.new
GC.start
# => finalize
Sample.new
sample.undef
GC.star...