るりまサーチ

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

別のキーワード

  1. openssl p
  2. openssl p=
  3. fileutils mkdir_p
  4. dh p=
  5. rsa p=

クラス

モジュール

キーワード

検索結果

Complex#<=>(other) -> -1 | 0 | 1 | nil (27249.0)

self の虚部がゼロで other が実数の場合、 self の実部の <=> メソッドで other と比較した結果を返します。 other が Complex で虚部がゼロの場合も同様です。

... <=> メソッドで other と比較した結果を返します。
other が Complex で虚部がゼロの場合も同様です。

その他の場合は nil を返します。

@param other 自身と比較する数値

//emlist[例][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
//}...

Time#<=>(other) -> -1 | 0 | 1 | nil (24299.0)

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
//...

String#<=>(other) -> -1 | 0 | 1 | nil (24281.0)

self と other を ASCII コード順で比較して、 self が大きい時には 1、等しい時には 0、小さい時には -1 を返します。 このメソッドは Comparable モジュールのメソッドを実装するために使われます。

...ッドは Comparable モジュールのメソッドを実装するために使われます。

other が文字列でない場合、
other.to_str と other.<=> が定義されていれば
0 - (other <=> self) の結果を返します。
そうでなければ nil を返します。

@param other...
...文字列
@return 比較結果の整数か nil

//emlist[例][ruby]{
p
"aaa" <=> "xxx" # => -1
p
"aaa" <=> "aaa" # => 0
p
"xxx" <=> "aaa" # => 1

p
"string" <=> "stringAA" # => -1
p
"string" <=> "string" # => 0
p
"stringAA" <=> "string" # => 1
//}...

Module#<=>(other) -> Integer | nil (24275.0)

self と other の継承関係を比較します。

...@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 <=> O...

Symbol#<=>(other) -> -1 | 0 | 1 | nil (24251.0)

self と other のシンボルに対応する文字列を ASCII コード順で比較して、 self が小さい時には -1、等しい時には 0、大きい時には 1 を返します。

...er がシンボルではなく比較できない時には nil を返します。

@param other 比較対象のシンボルを指定します。

//emlist[][ruby]{
p
:aaa <=> :xxx # => -1
p
:aaa <=> :aaa # => 0
p
:xxx <=> :aaa # => 1
p
:foo <=> "foo" # => nil
//}

@see String#<=>, Symbol#casecmp...

絞り込み条件を変える

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

ファイルの最終更新時刻を比較します。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
//}...

Comparable#<=(other) -> bool (21159.0)

比較演算子 <=> をもとにオブジェクト同士を比較します。 <=> が負の整数か 0 を返した場合に、true を返します。 それ以外の整数を返した場合に、false を返します。

...比較演算子 <=> をもとにオブジェクト同士を比較します。
<=>
が負の整数か 0 を返した場合に、true を返します。
それ以外の整数を返した場合に、false を返します。

@param other 自身と比較したいオブジェクトを指定します。...
...@raise ArgumentError <=> が nil を返したときに発生します。

//emlist[例][ruby]{
1 <= 0 # => false
1 <= 1 # => true
1 <= 2 # => true
//}...

Comparable#between?(min, max) -> bool (3037.0)

比較演算子 <=> をもとに self が min と max の範囲内(min, max を含みます)にあるかを判断します。

...演算子 <=> をもとに self が min と max の範囲内(min, max
を含みます)にあるかを判断します。

以下のコードと同じです。
//emlist[][ruby]{
self >= min and self <= max
//}

@param min 範囲の下端を表すオブジェクトを指定します。

@param max 範...
...囲の上端を表すオブジェクトを指定します。

@raise ArgumentError self <=> min か、self <=> max が nil を返
したときに発生します。

//emlist[例][ruby]{
3.between?(1, 5) # => true
6.between?(1, 5) # => false
'cat'.betw...

Range#cover?(obj) -> bool (29.0)

obj が範囲内に含まれている時に true を返します。

...obj が範囲内に含まれている時に true を返します。

Range#include? と異なり <=> メソッドによる演算により範囲内かどうかを判定します。
Range#include? は原則として離散値を扱い、
Range#cover? は連続値を扱います。
(数値につい...
...、例外として Range#include? も連続的に扱います。)

Range#exclude_end?がfalseなら「begin <= obj <= end」を、
trueなら「begin <= obj < end」を意味します。

@param obj 比較対象のオブジェクトを指定します。

//emlist[数値は連続的に扱われて...

Range#cover?(range) -> bool (19.0)

2.6 以降の cover? は、Range#include? や Range#=== と異なり、 引数に Range オブジェクトを指定して比較できます。

...比較できます。

引数が Range オブジェクトの場合、引数の範囲が self の範囲に含まれる時に true を返します。

@param range 比較対象の Range クラスのインスタンスを指定します。

//emlist[引数が Range の例][ruby]{
(1..5).cover?(2..3)...
...r?(1...6) #=> true
//}

「(a..b).cover?(c...d)」のように終端を含まない Range オブジェクトが引数に渡されており、
「a <= c && b < d」を満たし、cが数値ではない(つまり引数の Range の終端を
求めるために succ メソッドの呼び出しが必...
...要な)場合、パフォーマンスの問題が起きる可能性があります。

//emlist[パフォーマンス上の問題が起きる例][ruby]{
p
('aaaaa'..'zzzzy').cover?('aaaaa'...'zzzzz') # => true
//}

@see Range#include?, Range#===...

絞り込み条件を変える