クラス
- Array (9)
-
Fiddle
:: Pointer (11) -
File
:: Stat (11) - IPAddr (11)
- Integer (22)
- Module (11)
- Numeric (84)
キーワード
- <=> (55)
-
bsearch
_ index (9) - step (84)
検索結果
先頭5件
-
Integer
# <=(other) -> bool (48318.0) -
比較演算子。数値として等しいまたは小さいか判定します。
...other 比較対象の数値
@return self よりも other の方が大きい場合か、
両者が等しい場合 true を返します。
そうでなければ false を返します。
//emlist[][ruby]{
1 <= 0 # => false
1 <= 1 # => true
1 <= 2 # => true
//}... -
Integer
# <=>(other) -> -1 | 0 | 1 | nil (42300.0) -
self と other を比較して、self が大きい時に1、等しい時に 0、小さい時 に-1、比較できない時に nil を返します。
...lf と other を比較して、self が大きい時に1、等しい時に 0、小さい時
に-1、比較できない時に nil を返します。
@param other 比較対象の数値
@return -1 か 0 か 1 か nil のいずれか
//emlist[][ruby]{
1 <=> 2 # => -1
1 <=> 1 # => 0
2 <=> 1 # =>......1
2 <=> '' # => nil
//}... -
File
:: Stat # <=>(o) -> Integer | nil (15502.0) -
ファイルの最終更新時刻を比較します。self が other よりも 新しければ正の数を、等しければ 0 を古ければ負の数を返します。 比較できない場合は nil を返します。
...self が other よりも
新しければ正の数を、等しければ 0 を古ければ負の数を返します。
比較できない場合は nil を返します。
@param o File::Stat のインスタンスを指定します。
//emlist[][ruby]{
require 'tempfile' # for Tempfile
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
//}... -
Module
# <=>(other) -> Integer | nil (15502.0) -
self と other の継承関係を比較します。
...elf と other の継承関係を比較します。
self と other を比較して、
self が other の子孫であるとき -1、
同一のクラス/モジュールのとき 0、
self が other の先祖であるとき 1
を返します。
継承関係にないクラス同士の比較では
nil......nil を返します。
@param other 比較対象のクラスやモジュール
//emlist[例][ruby]{
module Foo
end
class Bar
include Foo
end
class Baz < Bar
end
class Qux
end
p Bar <=> Foo # => -1
p Baz <=> Bar # => -1
p Baz <=> Foo # => -1
p Baz <=> Qux # => nil
p Qux <=> Baz......# => nil
p Baz <=> Object.new # => nil
//}... -
Fiddle
:: Pointer # <=>(other) -> Integer (15402.0) -
ポインタの指すアドレスの大小を比較します。
ポインタの指すアドレスの大小を比較します。
other より小さい場合は -1, 等しい場合は 0、other より大きい場合は
1を返します。
@param other 比較対象の Pointer オブジェクト -
IPAddr
# <=>(other) -> Integer | nil (12526.0) -
self と other を比較します。
...self と other を比較します。
@param other 比較対象の IPAddr オブジェクト。
@return self と other のアドレスファミリが一致しない場合は nil を返します。
アドレスファミリが一致する場合は、両方の数値表現を Integer#<=>......で比較した結果を返します。
@see Integer#<=>... -
Array
# bsearch _ index { |x| . . . } -> Integer | nil (414.0) -
ブロックの評価結果で範囲内の各要素の判定を行い、条件を満たす値の位置を 二分探索(計算量は O(log n))で検索します。要素が見つからない場合は nil を返します。self はあらかじめソートしておく必要があります。
...範囲内の各要素の判定を行い、条件を満たす値の位置を
二分探索(計算量は O(log n))で検索します。要素が見つからない場合は nil
を返します。self はあらかじめソートしておく必要があります。
本メソッドはArray#bsearchと同......してください。
//emlist[例: find-minimum モード][ruby]{
ary = [0, 4, 7, 10, 12]
ary.bsearch_index { |x| x >= 4 } # => 1
ary.bsearch_index { |x| x >= 6 } # => 2
ary.bsearch_index { |x| x >= -1 } # => 0
ary.bsearch_index { |x| x >= 100 } # => nil
//}
//emlist[例: find-any モード]......[ruby]{
ary = [0, 4, 7, 10, 12]
# 4 <= v < 8 になる要素の位置を検索
ary.bsearch_index { |x| 1 - x / 4 } # => 2
# 8 <= v < 10 になる要素の位置を検索
ary.bsearch_index { |x| 4 - x / 2 } # => nil
//}
@see Array#bsearch... -
Numeric
# step(by: 1 , to: Float :: INFINITY) -> Enumerator (218.0) -
self からはじめ step を足しながら limit を越える 前までブロックを繰り返します。step は負の数も指定できます。また、limit や step には Float なども 指定できます。
...self からはじめ step を足しながら limit を越える
前までブロックを繰り返します。step は負の数も指定できます。また、limit や step には Float なども
指定できます。
@param limit ループの上限あるいは下限を数値で指定します。......では誤差が
生じて意図した回数ループしないことがある。step はこの誤差を考慮し
て実装されている。
//emlist[例][ruby]{
i = 1.1
while i <= 1.5
p i
i += 0.1
end
# => 1.1
# 1.2
# 1.3
# 1.4 <- 1.5 が表示されない
//}
@see Integer#downto... -
Numeric
# step(by: 1 , to: Float :: INFINITY) -> Enumerator :: ArithmeticSequence (218.0) -
self からはじめ step を足しながら limit を越える 前までブロックを繰り返します。step は負の数も指定できます。また、limit や step には Float なども 指定できます。
...self からはじめ step を足しながら limit を越える
前までブロックを繰り返します。step は負の数も指定できます。また、limit や step には Float なども
指定できます。
@param limit ループの上限あるいは下限を数値で指定します。......では誤差が
生じて意図した回数ループしないことがある。step はこの誤差を考慮し
て実装されている。
//emlist[例][ruby]{
i = 1.1
while i <= 1.5
p i
i += 0.1
end
# => 1.1
# 1.2
# 1.3
# 1.4 <- 1.5 が表示されない
//}
@see Integer#downto... -
Numeric
# step(by: 1 , to: Float :: INFINITY) {|n| . . . } -> self (218.0) -
self からはじめ step を足しながら limit を越える 前までブロックを繰り返します。step は負の数も指定できます。また、limit や step には Float なども 指定できます。
...self からはじめ step を足しながら limit を越える
前までブロックを繰り返します。step は負の数も指定できます。また、limit や step には Float なども
指定できます。
@param limit ループの上限あるいは下限を数値で指定します。......では誤差が
生じて意図した回数ループしないことがある。step はこの誤差を考慮し
て実装されている。
//emlist[例][ruby]{
i = 1.1
while i <= 1.5
p i
i += 0.1
end
# => 1.1
# 1.2
# 1.3
# 1.4 <- 1.5 が表示されない
//}
@see Integer#downto...