種類
- インスタンスメソッド (190)
- 文書 (22)
- クラス (11)
ライブラリ
- ビルトイン (168)
- fiddle (11)
- ipaddr (11)
-
rubygems
/ dependency (11)
クラス
- Array (18)
-
Fiddle
:: Pointer (11) -
File
:: Stat (11) -
Gem
:: Dependency (11) - IPAddr (11)
- Integer (22)
- Module (11)
- Numeric (95)
キーワード
-
1
. 6 . 8から1 . 8 . 0への変更点(まとめ) (11) - <=> (66)
- Numeric (11)
-
bsearch
_ index (18) - div (11)
-
ruby 1
. 6 feature (11) - step (84)
検索結果
先頭5件
-
Integer
# <=(other) -> bool (39118.0) -
比較演算子。数値として等しいまたは小さいか判定します。
...other 比較対象の数値
@return self よりも other の方が大きい場合か、
両者が等しい場合 true を返します。
そうでなければ false を返します。
//emlist[][ruby]{
1 <= 0 # => false
1 <= 1 # => true
1 <= 2 # => true
//}... -
Integer
# <=>(other) -> -1 | 0 | 1 | nil (27100.0) -
self と other を比較して、self が大きい時に1、等しい時に 0、小さい時 に-1、比較できない時に nil を返します。
...、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
//}... -
IPAddr
# <=>(other) -> Integer | nil (6213.0) -
self と other を比較します。
...の IPAddr オブジェクト。
@return self と other のアドレスファミリが一致しない場合は nil を返します。
アドレスファミリが一致する場合は、両方の数値表現を Integer#<=>
で比較した結果を返します。
@see Integer#<=>... -
Fiddle
:: Pointer # <=>(other) -> Integer (6201.0) -
ポインタの指すアドレスの大小を比較します。
ポインタの指すアドレスの大小を比較します。
other より小さい場合は -1, 等しい場合は 0、other より大きい場合は
1を返します。
@param other 比較対象の Pointer オブジェクト -
File
:: Stat # <=>(o) -> Integer | nil (6201.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
//}... -
Gem
:: Dependency # <=>(other) -> Integer (6201.0) -
self と other を Gem::Dependency#name の ASCII コードで比較して self が大きい時には正の整数、等しい時には 0、小さい時には負の整数を返します。
self と other を Gem::Dependency#name の ASCII コードで比較して
self が大きい時には正の整数、等しい時には 0、小さい時には負の整数を返します。 -
Module
# <=>(other) -> Integer | nil (6201.0) -
self と 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
//}... -
Array
# bsearch _ index { |x| . . . } -> Integer | nil (113.0) -
ブロックの評価結果で範囲内の各要素の判定を行い、条件を満たす値の位置を 二分探索(計算量は O(log n))で検索します。要素が見つからない場合は nil を返します。self はあらかじめソートしておく必要があります。
...ndex { |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#... -
Numeric
# div(other) -> Integer (113.0) -
self を other で割った整数の商 q を返します。
...ます。
ここで、商 q と余り r は、それぞれ
* self == other * q + r
と
* other > 0 のとき: 0 <= r < other
* other < 0 のとき: other < r <= 0
* q は整数
をみたす数です。
商に対応する余りは Numeric#modulo で求められます。
div はメ... -
Numeric (82.0)
-
数値を表す抽象クラスです。Integer や Float などの数値クラス は Numeric のサブクラスとして実装されています。
...数値を表す抽象クラスです。Integer や Float などの数値クラス
は Numeric のサブクラスとして実装されています。
演算や比較を行うメソッド(+, -, *, /, <=>)は Numeric のサブクラスで定義されま
す。Numeric で定義されているメソッ......れているメソッドは、Numeric のサブクラスとして新たに数値クラスを定義した時に、
演算メソッド(+, -, *, /, %, <=>, coerce)だけを定義すれば、数値クラスのそのほかのメソッドが
適切に定義されることを意図して提供されてい......れのクラスを参照してください。
=> ruby 2.1.2p95 (2014-05-08 revision 45877) [x86_64-linux]
Numeric Integer Fixnum Bignum Float Rational Complex
------------------------------------------------------------------------------......クラスを参照してください。
=> ruby 2.4.2p198 (2017-09-14 revision 59899) [x86_64-darwin15]
Numeric Integer Float Rational Complex
--------------------------------------------------------------------------------
% |...