るりまサーチ

最速Rubyリファレンスマニュアル検索!
4033件ヒット [101-200件を表示] (0.299秒)

別のキーワード

  1. _builtin inspect
  2. _builtin []
  3. _builtin to_s
  4. _builtin each

ライブラリ

モジュール

キーワード

検索結果

<< < 1 2 3 4 ... > >>

Enumerable#min(n) {|a, b| ... } -> Array (8055.0)

ブロックの評価結果で各要素の大小判定を行い、最小の要素、もしくは最小の n 要素が昇順で入った配列を返します。 引数を指定しない形式では要素が存在しなければ nil を返します。 引数を指定する形式では、空の配列を返します。

...ge = age
end
end

people = [
Person.new("sato", 55),
Person.new("sato", 33),
Person.new("sato", 11),
Person.new("suzuki", 55),
Person.new("suzuki", 33),
Person.new("suzuki", 11),
Person.new("tanaka", 55),
Person.new("tanaka", 33),
Person.new("tanaka", 11)
]

# 年齢が最小、...

Proc#lambda? -> bool (8055.0)

手続きオブジェクトの引数の取扱が厳密であるならば true を返します。

...bda{}.lambda? # => true
# proc で生成した Proc オブジェクトでは false
proc{}.lambda? # => false
# Proc.new で生成した Proc オブジェクトでは false
Proc.new{}.lambda? # => false

# 以下、lambda?が偽である場合
# 余分な引数を無視する
proc{|a,b| [a,b]}.call...
...{}).lambda? #=> true
Proc.new(&lambda {}).lambda? #=> true

lambda(&proc {}).lambda? #=> false
proc(&proc {}).lambda? #=> false
Proc.new(&proc {}).lambda? #=> false

n(&lambda {}) #=> true
n(&proc {}) #=> false
n(&Proc.new {}) #=> false

#...
...ソッドの引数は常に厳密に取り扱われる
class C
define_method(:d) {}
end
C.new.d(1,2) #=> ArgumentError
C.new.method(:d).to_proc.lambda? #=> true

class C
define_method(:e, &proc {})
end
C.new.e(1,2) #=> ArgumentError
C.new.method(:e).to_proc.lambda? #=> true
//}...

Random#rand -> Float (8055.0)

一様な擬似乱数を発生させます。

...が存在しない範囲を渡した時などに発生します。

//emlist[例][ruby]{
# Kernel.#rand とほぼ同様の使い勝手
prng = Random.new(1234)
prng.rand # => 0.1915194503788923
srand(1234)
rand # => 0.1915194503788923

# max に実数も指定出来る
prng...
...
prng.rand(Time.new(2012, 1, 1) ... Time.new(2013,1,1)) # => 2012-02-25 03:11:42 +0900
require 'date'
prng.rand(Date.new(2012, 1, 1) ... Date.new(2013,1,1)) # => #<Date: 2012-01-31 ((2455958j,0s,0n),+0s,2299161j)>
# Kernel.#rand とほぼ同様の使い勝手
prng = Random.new(1234)
prng.rand...
...3.6148130397862865
# 2012年のすべての時刻から一つ選ばれる
# Time#- は秒数を float で返すため。
prng.rand(Time.new(2012, 1, 1) ... Time.new(2013,1,1)) # => 2012-02-25 03:11:42 +0900
# DateTime ではうまくいかない。というのは DateTime#- は
# Rational を返す...

Random#rand(max) -> Integer | Float (8055.0)

一様な擬似乱数を発生させます。

...が存在しない範囲を渡した時などに発生します。

//emlist[例][ruby]{
# Kernel.#rand とほぼ同様の使い勝手
prng = Random.new(1234)
prng.rand # => 0.1915194503788923
srand(1234)
rand # => 0.1915194503788923

# max に実数も指定出来る
prng...
...
prng.rand(Time.new(2012, 1, 1) ... Time.new(2013,1,1)) # => 2012-02-25 03:11:42 +0900
require 'date'
prng.rand(Date.new(2012, 1, 1) ... Date.new(2013,1,1)) # => #<Date: 2012-01-31 ((2455958j,0s,0n),+0s,2299161j)>
# Kernel.#rand とほぼ同様の使い勝手
prng = Random.new(1234)
prng.rand...
...3.6148130397862865
# 2012年のすべての時刻から一つ選ばれる
# Time#- は秒数を float で返すため。
prng.rand(Time.new(2012, 1, 1) ... Time.new(2013,1,1)) # => 2012-02-25 03:11:42 +0900
# DateTime ではうまくいかない。というのは DateTime#- は
# Rational を返す...

Random#rand(range) -> Integer | Float (8055.0)

一様な擬似乱数を発生させます。

...が存在しない範囲を渡した時などに発生します。

//emlist[例][ruby]{
# Kernel.#rand とほぼ同様の使い勝手
prng = Random.new(1234)
prng.rand # => 0.1915194503788923
srand(1234)
rand # => 0.1915194503788923

# max に実数も指定出来る
prng...
...
prng.rand(Time.new(2012, 1, 1) ... Time.new(2013,1,1)) # => 2012-02-25 03:11:42 +0900
require 'date'
prng.rand(Date.new(2012, 1, 1) ... Date.new(2013,1,1)) # => #<Date: 2012-01-31 ((2455958j,0s,0n),+0s,2299161j)>
# Kernel.#rand とほぼ同様の使い勝手
prng = Random.new(1234)
prng.rand...
...3.6148130397862865
# 2012年のすべての時刻から一つ選ばれる
# Time#- は秒数を float で返すため。
prng.rand(Time.new(2012, 1, 1) ... Time.new(2013,1,1)) # => 2012-02-25 03:11:42 +0900
# DateTime ではうまくいかない。というのは DateTime#- は
# Rational を返す...

絞り込み条件を変える

Regexp#options -> Integer (8049.0)

正規表現の生成時に指定されたオプションを返します。戻り値は、 Regexp::EXTENDED, Regexp::IGNORECASE, Regexp::MULTILINE, Regexp::FIXEDENCODING, Regexp::NOENCODING, の論理和です。

...るもので、Regexp.new にこれらを
渡しても無視されます。

//emlist[例][ruby]{
p Regexp::IGNORECASE # => 1
p //i.options # => 1

p Regexp.new("foo", Regexp::IGNORECASE ).options # => 1
p Regexp.new("foo", Regexp::EXTENDED).options # => 2
p Regexp.new("foo", Regexp::IGNOR...
...ASE | Regexp::EXTENDED).options # => 3
p Regexp.new("foo", Regexp::MULTILINE).options # => 4
p Regexp.new("foo", Regexp::IGNORECASE | Regexp::MULTILINE ).options # => 5
p Regexp.new("foo", Regexp::MULTILINE | Regexp::EXTENDED).options # =>6
p Regexp.new("foo", Regexp::IGNORECASE | Regexp::MULTILINE...

Time#wday -> Integer (8043.0)

曜日を0(日曜日)から6(土曜日)の整数で返します。

...= Time.new(2017, 9, 17, 10, 34, 15, '+09:00') # => 2017-09-17 10:34:15 +0900
p sun.wday # => 0
p mon = Time.new(2017, 9, 18, 10, 34, 15, '+09:00') # => 2017-09-18 10:34:15 +0900
p mon.wday # => 1
p tue = Time.new(2017,...
...= Time.new(2017, 9, 20, 10, 34, 15, '+09:00') # => 2017-09-20 10:34:15 +0900
p wed.wday # => 3
p thu = Time.new(2017, 9, 21, 10, 34, 15, '+09:00') # => 2017-09-21 10:34:15 +0900
p thu.wday # => 4
p fri = Time.new(2017,...
...9, 22, 10, 34, 15, '+09:00') # => 2017-09-22 10:34:15 +0900
p fri.wday # => 5
p sat = Time.new(2017, 9, 23, 10, 34, 15, '+09:00') # => 2017-09-23 10:34:15 +0900
p sat.wday # => 6
//}...

Encoding::Converter#primitive_errinfo -> Array (8037.0)

直前の Encoding::Converter#primitive_convert による変換の結果を保持する五要素の配列を返します。

...ることはできますが、有用な使い方は難しいでしょう。

//emlist[][ruby]{
# \xff is invalid as EUC-JP.
ec = Encoding::Converter.new("EUC-JP", "Shift_JIS")
ec.primitive_convert(src="\xff", dst="", nil, 10)
p ec.primitive_errinfo
#=> [:invalid_byte_sequence, "EUC-JP", "Shift_JIS",...
...\x82).
ec = Encoding::Converter.new("EUC-JP", "ISO-8859-1")
ec.primitive_convert(src="\xa4\xa2", dst="", nil, 10)
p ec.primitive_errinfo
#=> [:undefined_conversion, "UTF-8", "ISO-8859-1", "\xE3\x81\x82", ""]

# partial character is invalid
ec = Encoding::Converter.new("EUC-JP", "ISO-8859-1")
ec.prim...
...nput, "EUC-JP", "UTF-8", "\xA4", ""]

# Encoding::Converter::PARTIAL_INPUT prevents invalid errors by
# partial characters.
ec = Encoding::Converter.new("EUC-JP", "ISO-8859-1")
ec.primitive_convert(src="\xa4", dst="", nil, 10, Encoding::Converter::PARTIAL_INPUT)
p ec.primitive_errinfo
#=> [:source_b...

ThreadGroup#enclose -> self (8037.0)

自身への ThreadGroup#add によるスレッドの追加・削除を禁止します。 enclose された ThreadGroup に追加や削除を行うと例外 ThreadError が発生します。

...ead.new によるスレッドの追加は禁止されません。enclose されたスレッドグループ A に
属するスレッドが新たにスレッドを生成した場合、生成されたスレッドはスレッドグループ A に属します。

追加の例:

thg = ThreadGroup.new.en...
...close
thg.add Thread.new {}

=> -:2:in `add': can't move to the enclosed thread group (ThreadError)

削除の例:

thg1 = ThreadGroup.new
thg2 = ThreadGroup.new

th = Thread.new {sleep 1}

thg1.add th
thg1.enclose
thg2.add th

=> -:8:in `add': can't move from the enclosed thread g...

File::Stat#<=>(o) -> Integer | nil (8031.0)

ファイルの最終更新時刻を比較します。self が other よりも 新しければ正の数を、等しければ 0 を古ければ負の数を返します。 比較できない場合は nil を返します。

...fp1 = Tempfile.open("first")
fp1.print "古い方\n"
sleep(1)
fp2 = Tempfile.open("second")
fp2.print "新しい方\n"

p File::Stat.new(fp1.path) <=> File::Stat.new(fp2.path) #=> -1
p File::Stat.new(fp2.path) <=> File::Stat.new(fp1.path) #=> 1
p File::Stat.new(fp1.path) <=> fp2.path #=> nil
//}...

絞り込み条件を変える

<< < 1 2 3 4 ... > >>