ライブラリ
- English (99)
- ビルトイン (129)
- csv (11)
- drb (11)
- fileutils (11)
- pathname (33)
- rake (110)
-
rake
/ loaders / makefile (11) -
rake
/ packagetask (176)
クラス
- Array (44)
- NameError (9)
- Object (11)
- Pathname (33)
- Proc (11)
-
Rake
:: Application (11) -
Rake
:: FileList (11) -
Rake
:: MakefileLoader (11) -
Rake
:: NameSpace (11) -
Rake
:: PackageTask (176) - Random (33)
モジュール
- FileUtils (11)
- Kernel (109)
- ObjectSpace (11)
-
Rake
:: TaskManager (33) - RakeFileUtils (44)
キーワード
-
$ ARGV (11) -
$ DEFAULT _ INPUT (11) -
$ ERROR _ INFO (11) -
$ ERROR _ POSITION (11) -
$ INPUT _ LINE _ NUMBER (11) -
$ LAST _ PAREN _ MATCH (11) -
$ NR (11) -
$ ORS (11) -
$ OUTPUT _ RECORD _ SEPARATOR (11) -
1
. 6 . 8から1 . 8 . 0への変更点(まとめ) (11) - CSV (11)
- DRbProtocol (11)
-
NEWS for Ruby 2
. 0 . 0 (11) -
NEWS for Ruby 2
. 3 . 0 (9) - abort (10)
-
add
_ loader (11) -
bigdecimal
/ ludcmp (11) -
bigdecimal
/ newton (11) - binding (11)
-
cgi
/ session (11) -
cp
_ r (11) - delete (11)
- egrep (11)
- find (11)
-
in
_ namespace (11) - intern (11)
- irb (11)
- load (11)
- logger (11)
- name (11)
- name= (11)
-
need
_ tar (11) -
need
_ tar= (11) -
need
_ tar _ bz2 (11) -
need
_ tar _ bz2= (11) -
need
_ tar _ gz (11) -
need
_ tar _ gz= (11) -
need
_ zip (11) -
need
_ zip= (11) - new (22)
-
nowrite
_ flag (11) -
nowrite
_ flag= (11) - optparse (11)
-
package
_ dir (11) -
package
_ dir= (11) -
package
_ dir _ path (11) -
package
_ files (11) -
package
_ files= (11) - profile (6)
- rand (33)
- receiver (9)
-
respond
_ to _ missing? (11) -
rinda
/ rinda (11) - rss (11)
-
ruby 1
. 8 . 4 feature (11) - split (11)
-
synthesize
_ file _ task (11) -
undefine
_ finalizer (11) - unlink (11)
-
verbose
_ flag (11) -
verbose
_ flag= (11) - xmlrpc (3)
検索結果
先頭5件
-
Array
# sample -> object | nil (18122.0) -
配列の要素を1個(引数を指定した場合は自身の要素数を越えない範囲で n 個) ランダムに選んで返します。
...した場合に発生します。
@raise ArgumentError 引数 n に負の数を指定した場合に発生します。
//emlist[例][ruby]{
a = (1..10).to_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]
//}... -
Array
# sample(n) -> Array (18122.0) -
配列の要素を1個(引数を指定した場合は自身の要素数を越えない範囲で n 個) ランダムに選んで返します。
...した場合に発生します。
@raise ArgumentError 引数 n に負の数を指定した場合に発生します。
//emlist[例][ruby]{
a = (1..10).to_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]
//}... -
Array
# sample(n , random: Random) -> Array (18122.0) -
配列の要素を1個(引数を指定した場合は自身の要素数を越えない範囲で n 個) ランダムに選んで返します。
...した場合に発生します。
@raise ArgumentError 引数 n に負の数を指定した場合に発生します。
//emlist[例][ruby]{
a = (1..10).to_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]
//}... -
Array
# sample(random: Random) -> object | nil (18122.0) -
配列の要素を1個(引数を指定した場合は自身の要素数を越えない範囲で n 個) ランダムに選んで返します。
...した場合に発生します。
@raise ArgumentError 引数 n に負の数を指定した場合に発生します。
//emlist[例][ruby]{
a = (1..10).to_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]
//}... -
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... -
Rake
:: MakefileLoader # load(filename) (24.0) -
与えられた Makefile をロードします。
...open "sample.mf", "w" do |io|
io << <<-'SAMPLE_MF'
# Comments
a: a1 a2 a3 a4
b: b1 b2 b3 \
b4 b5 b6\
# Mid: Comment
b7
a : a5 a6 a7
c: c1
d: d1 d2 \
e f : e1 f1
g\ 0: g1 g\ 2 g\ 3 g4
SAMPLE_MF
end
task :test_rake_app do |task|
loader = Rake::MakefileLoader.new
loader.load("sample.mf")...