るりまサーチ

最速Rubyリファレンスマニュアル検索!
324件ヒット [1-100件を表示] (0.043秒)

別のキーワード

  1. rbconfig ruby
  2. fiddle ruby_free
  3. fiddle build_ruby_platform
  4. rake ruby
  5. rubygems/defaults ruby_engine

ライブラリ

キーワード

検索結果

<< 1 2 3 ... > >>

Array#sample -> object | nil (18147.0)

配列の要素を1個(引数を指定した場合は自身の要素数を越えない範囲で 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]
//}

random SecureRandom などの乱数生成器を渡すことができます。

//emlist[例][ruby]{
require
'securerandom...
...'
a = (1..10).to_a
p a.sample(random: SecureRandom) #=> 2
//}...

Array#sample(n) -> Array (18147.0)

配列の要素を1個(引数を指定した場合は自身の要素数を越えない範囲で 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]
//}

random SecureRandom などの乱数生成器を渡すことができます。

//emlist[例][ruby]{
require
'securerandom...
...'
a = (1..10).to_a
p a.sample(random: SecureRandom) #=> 2
//}...

Array#sample(n, random: Random) -> Array (18147.0)

配列の要素を1個(引数を指定した場合は自身の要素数を越えない範囲で 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]
//}

random SecureRandom などの乱数生成器を渡すことができます。

//emlist[例][ruby]{
require
'securerandom...
...'
a = (1..10).to_a
p a.sample(random: SecureRandom) #=> 2
//}...

Array#sample(random: Random) -> object | nil (18147.0)

配列の要素を1個(引数を指定した場合は自身の要素数を越えない範囲で 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]
//}

random SecureRandom などの乱数生成器を渡すことができます。

//emlist[例][ruby]{
require
'securerandom...
...'
a = (1..10).to_a
p a.sample(random: SecureRandom) #=> 2
//}...

Rake::MakefileLoader#load(filename) (37.0)

与えられた Makefile をロードします。

...ilename 読み込む Makefile の名前を指定します。

//emlist[][ruby]{
# Rakefile での記載例とする
require
"rake/loaders/makefile"

task default: :test_rake_app

open "sample.mf", "w" do |io|
io << <<-'SAMPLE_MF'
# Comments
a: a1 a2 a3 a4
b: b1 b2 b3 \
b4 b5 b6\
# Mid: Comment...
...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")
p Rake::Task.task_defined?("a") # => true
p Rake::Task.tasks[0] # => <Rake::FileTask a => [a1, a2, a3, a4, a5, a6, a7]>
end
//}...

絞り込み条件を変える

Rake::Application#add_loader(ext, loader) (31.0)

与えられた拡張子で終わるファイル名のファイルをロードするためのローダーを 自身に追加します。

...oader ローダーを指定します。

//emlist[例][ruby]{
require
"rake/loaders/makefile"

# Rakefile での記載例とする

task default: :test
task :test

makefile =<<-EOS
<< <<-'SAMPLE_MF'
# Comments
a: a1 a2 a3 a4
EOS
IO.write("sample.mf", makefile)
Rake.application.add_loader("mf", Rake:...

Pathname#split -> Array (25.0)

File.split(self.to_s) と同じです。

...File.split(self.to_s) と同じです。

//emlist[例][ruby]{
require
"pathname"

pathname = Pathname("/path/to/sample")
pathname.split # => [#<Pathname:/path/to>, #<Pathname:sample>]
//}

@see File.split...

Rake::PackageTask#name -> String (25.0)

バージョン情報を含まないパッケージの名前を返します。

...バージョン情報を含まないパッケージの名前を返します。

//emlist[][ruby]{
# Rakefile での記載例とする
require
'rake/packagetask'

Rake::PackageTask.new("sample", "1.0.0") do |package_task|
package_task.name # => "sample"
end
//}...

Rake::PackageTask#name=(name) (25.0)

バージョン情報を含まないパッケージの名前をセットします。

...param name パッケージの名前を指定します。

//emlist[][ruby]{
# Rakefile での記載例とする
require
'rake/packagetask'

Rake::PackageTask.new("sample", "1.0.0") do |package_task|
package_task.name # => "sample"
package_task.name = "update"
package_task.name # => "update"
en...
<< 1 2 3 ... > >>