種類
- インスタンスメソッド (770)
- 文書 (60)
- クラス (11)
- 特異メソッド (11)
ライブラリ
- ビルトイン (726)
- date (11)
-
fiddle
/ import (11) - openssl (22)
- pathname (11)
-
rubygems
/ version (11)
クラス
モジュール
- Comparable (79)
- Enumerable (264)
-
Fiddle
:: Importer (11)
キーワード
-
1
. 6 . 8から1 . 8 . 0への変更点(まとめ) (11) - < (11)
- <= (11)
- == (11)
- === (5)
- > (11)
- >= (11)
-
NEWS for Ruby 2
. 7 . 0 (5) - Numeric (11)
- Rubyで使われる記号の意味(正規表現の複雑な記号は除く) (11)
- Ruby用語集 (11)
- between? (11)
- bind (11)
- clamp (13)
- cmp (11)
- cover? (17)
- include? (11)
- max (102)
-
max
_ by (44) - member? (11)
- min (102)
-
min
_ by (44) - minmax (42)
-
minmax
_ by (22) - new (11)
- nonzero? (11)
-
ruby 1
. 8 . 3 feature (11) - sort (44)
- sort! (22)
-
sort
_ by (22) - 演算子式 (11)
検索結果
先頭5件
-
Module
# <=>(other) -> Integer | nil (21466.0) -
self と other の継承関係を比較します。
...self と other の継承関係を比較します。
self と other を比較して、
self が other の子孫であるとき -1、
同一のクラス/モジュールのとき 0、
self が other の先祖であるとき 1
を返します。
継承関係にないクラス同士の比較では
n......other がクラスやモジュールでなければ
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
//}... -
Time
# <=>(other) -> -1 | 0 | 1 | nil (21419.0) -
self と other の時刻を比較します。self の方が大きい場合は 1 を、等しい場合は 0 を、 小さい場合は -1 を返します。比較できない場合は、nil を返します。
...self と other の時刻を比較します。self の方が大きい場合は 1 を、等しい場合は 0 を、
小さい場合は -1 を返します。比較できない場合は、nil を返します。
@param other 自身と比較したい時刻を Time オブジェクトで指定します。......//emlist[][ruby]{
p t = Time.local(2000) # => 2000-01-01 00:00:00 +0900
p t2 = t + 2592000 # => 2000-01-31 00:00:00 +0900
p t <=> t2 # => -1
p t2 <=> t # => 1
//}
//emlist[][ruby]{
p t = Time.local(2000) # => 2000-01-01 00:00:00 +0900
p t2 = t + 0.1 # =>......2000-01-01 00:00:00 +0900
p t.nsec # => 0
p t2.nsec # => 100000000
p t <=> t2 # => -1
p t2 <=> t # => 1
p t <=> t # => 0
//}... -
Date
# <=>(other) -> -1 | 0 | 1 | nil (21360.0) -
二つの日付を比較します。 同じ日付なら 0 を、self が other よりあとの日付なら 1 を、 その逆なら -1 を返します。
...self が other よりあとの日付なら 1 を、
その逆なら -1 を返します。
other は日付オブジェクトか、
天文学的なユリウス日をあらわす数値を指定します。
そうでない場合、比較ができないので nil を返します。
//emlist[][ruby]{
re......quire "date"
p Date.new(2001, 2, 3) <=> Date.new(2001, 2, 4) # => -1
p Date.new(2001, 2, 3) <=> Date.new(2001, 2, 3) # => 0
p Date.new(2001, 2, 3) <=> Date.new(2001, 2, 2) # => 1
p Date.new(2001, 2, 3) <=> Object.new # => nil
p Date.new(2001, 2, 3) <=> Rational(4903887, 2) # => 0
//}
@pa......ram other 日付オブジェクトまたは数値... -
Complex
# <=>(other) -> -1 | 0 | 1 | nil (21359.0) -
self の虚部がゼロで other が実数の場合、 self の実部の <=> メソッドで other と比較した結果を返します。 other が Complex で虚部がゼロの場合も同様です。
...self の虚部がゼロで other が実数の場合、
self の実部の <=> メソッドで other と比較した結果を返します。
other が Complex で虚部がゼロの場合も同様です。
その他の場合は nil を返します。
@param other 自身と比較する数値
//emlis......t[例][ruby]{
Complex(2, 3) <=> Complex(2, 3) #=> nil
Complex(2, 3) <=> 1 #=> nil
Complex(2) <=> 1 #=> 1
Complex(2) <=> 2 #=> 0
Complex(2) <=> 3 #=> -1
//}... -
Integer
# <=>(other) -> -1 | 0 | 1 | nil (21359.0) -
self と other を比較して、self が大きい時に1、等しい時に 0、小さい時 に-1、比較できない時に nil を返します。
...self と 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
//}... -
OpenSSL
:: BN # <=>(other) -> -1 | 0 | 1 (21354.0) -
自身と other を比較し、自身が小さいときには -1、 等しいときには 0、大きいときには 1 を返します。
...と other を比較し、自身が小さいときには -1、
等しいときには 0、大きいときには 1 を返します。
//emlist[][ruby]{
require 'openssl'
OpenSSL::BN.new(5) <=> 5 # => 0
OpenSSL::BN.new(5) <=> OpenSSL::BN.new(9) # => -1
OpenSSL::BN.new(5) <=> OpenSSL::BN.new(5) #......=> 0
OpenSSL::BN.new(5) <=> OpenSSL::BN.new(-5) # => 1
//}
@param other 比較する整数
@raise TypeError 比較できないときに発生します。
@see OpenSSL::BN#ucmp... -
Gem
:: Version # <=>(other) -> -1 | 0 | 1 | nil (21353.0) -
self と other を比較して、self が小さい時に -1、 等しい時に 0、大きい時に 1 の整数を返します。 また、other が Gem::Version ではなく比較できないとき、 nil を返します。
...self と other を比較して、self が小さい時に -1、
等しい時に 0、大きい時に 1 の整数を返します。
また、other が Gem::Version ではなく比較できないとき、 nil を返します。
//emlist[][ruby]{
p Gem::Version.new("3.9.0") <=> Gem::Version.new("3.10.......0") # => -1
p Gem::Version.new("3.0.0") <=> Gem::Version.new("3.0.0") # => 0
p Gem::Version.new("3.0.0") <=> Gem::Version.new("3.0") # => 0
p Gem::Version.new("3.9.0") <=> "3.9.0" # => nil
//}
@param other 比較対象の Gem::Version のインスタンスを指定します。... -
Numeric
# <=>(other) -> -1 | 0 | 1 | nil (21353.0) -
自身が other より大きい場合に 1 を、等しい場合に 0 を、小さい場合には -1 をそれぞれ返します。 自身と other が比較できない場合には nil を返します。
...自身が other より大きい場合に 1 を、等しい場合に 0 を、小さい場合には -1 をそれぞれ返します。
自身と other が比較できない場合には nil を返します。
Numeric のサブクラスは、上の動作を満たすよう このメソッドを適切に......再定義しなければなりません。
@param other 自身と比較したい数値を指定します。
//emlist[例][ruby]{
1 <=> 0 #=> 1
1 <=> 1 #=> 0
1 <=> 2 #=> -1
1 <=> "0" #=> nil
//}... -
Pathname
# <=>(other) -> -1 | 0 | 1 | nil (21331.0) -
パス名を比較します。other と同じなら 0 を、ASCII順で self が大きい場合 は正、other が大きい場合は負を返します。大文字小文字は区別されます。 other は Pathname オブジェクトでなければなりません。
...パス名を比較します。other と同じなら 0 を、ASCII順で self が大きい場合
は正、other が大きい場合は負を返します。大文字小文字は区別されます。
other は Pathname オブジェクトでなければなりません。
パス名の比較は単純に......er 比較対象の Pathname オブジェクトを指定します。
//emlist[例][ruby]{
require 'pathname'
p Pathname.new("foo/bar") <=> Pathname.new("foo/bar")
p Pathname.new("foo/bar") <=> Pathname.new("foo//bar")
p Pathname.new("foo/../foo/bar") <=> Pathname.new("foo/bar")
# => 0
# 1
# -... -
File
:: Stat # <=>(o) -> Integer | nil (21330.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
//}...