ライブラリ
- ビルトイン (1541)
-
cgi
/ core (24) - csv (24)
- date (12)
- delegate (12)
- digest (24)
- fiddle (24)
- matrix (48)
- openssl (60)
- ostruct (12)
- pathname (48)
- prime (24)
- rake (12)
-
rdoc
/ context (12) -
rexml
/ document (24) -
rubygems
/ package / tar _ header (12) -
rubygems
/ platform (24) -
rubygems
/ requirement (36) - set (24)
クラス
-
ARGF
. class (72) - Array (265)
- BasicObject (36)
- Bignum (9)
- CGI (24)
-
CSV
:: Row (12) -
CSV
:: Table (12) - Complex (12)
- Data (6)
- Date (12)
- Delegator (12)
-
Digest
:: Base (24) -
Enumerator
:: ArithmeticSequence (7) - Exception (12)
- FalseClass (36)
-
Fiddle
:: Pointer (24) - Fixnum (3)
- Float (36)
-
Gem
:: Package :: TarHeader (12) -
Gem
:: Platform (24) -
Gem
:: Requirement (36) - Hash (36)
- Integer (40)
- MatchData (24)
- Matrix (24)
- Method (56)
- Numeric (72)
- Object (60)
-
OpenSSL
:: BN (36) -
OpenSSL
:: PKey :: EC :: Group (24) - OpenStruct (12)
- Pathname (48)
- Prime (24)
-
Process
:: Status (12) -
RDoc
:: Context :: Section (12) -
REXML
:: Instruction (12) -
REXML
:: XMLDecl (12) -
Rake
:: FileList (12) - Random (12)
- Range (100)
- Rational (12)
- Regexp (36)
- Set (36)
- String (243)
- Struct (24)
- Symbol (12)
- Time (24)
- TrueClass (36)
- UnboundMethod (24)
- Vector (24)
モジュール
- Comparable (12)
- Enumerable (200)
キーワード
- != (12)
- % (12)
- & (24)
- === (139)
- =~ (12)
- [] (80)
- ^ (24)
- allbits? (8)
- call (16)
- clone (12)
- count (72)
- crypt (12)
- delete (24)
- detect (24)
- div (12)
- divmod (24)
- downcase (9)
- dup (12)
- each (60)
-
each
_ line (36) - eql? (186)
- equal? (12)
- find (24)
-
find
_ index (72) - getlocal (24)
- header (12)
- include? (8)
- index (36)
- join (12)
- max (86)
- member? (8)
- min (86)
- modulo (12)
- nobits? (8)
- none? (15)
- one? (45)
- out (12)
- pack (21)
- remainder (12)
- rindex (36)
-
satisfied
_ by? (12) - slice (72)
- split (19)
- sum (12)
-
unicode
_ normalize! (11) - unpack (12)
- | (24)
検索結果
先頭5件
-
MatchData
# ==(other) -> bool (21243.0) -
self と other のマッチ対象になった文字列、元になった正規表現オブジェク ト、マッチした位置が等しければ true を返します。そうでない場合には false を返します。
...と other のマッチ対象になった文字列、元になった正規表現オブジェク
ト、マッチした位置が等しければ true を返します。そうでない場合には
false を返します。
@param other 比較対象のオブジェクトを指定します。
//emlist[文.......match("a")
m2 = s.match("b")
m1 == m2 # => false
m2 = s.match("a")
m1 == m2 # => true
//}
//emlist[正規表現][ruby]{
r = /abc/
m1 = r.match("abc") # => #<MatchData "abc">
m2 = r.match("abcde") # => #<MatchData "abc">
m1 == m2 # => false
m2 = r.match("abc") # => #<MatchData "abc">
m1 == m......2 # => true
//}
//emlist[正規表現のマッチした位置][ruby]{
r = /abc/
m1 = r.match("abcabc") # => #<MatchData "abc">
m2 = r.match("abcabc", 3) # => #<MatchData "abc">
m1 == m2 # => false
m2 = r.match("abcabc", 0) # => #<MatchData "abc">
m1 == m2 # => true
//}... -
Exception
# ==(other) -> bool (21241.0) -
自身と指定された other のクラスが同じであり、 message と backtrace が == メソッドで比較して 等しい場合に true を返します。そうでない場合に false を返します。
...自身と指定された other のクラスが同じであり、
message と backtrace が == メソッドで比較して
等しい場合に true を返します。そうでない場合に false を返します。
@param other 自身と比較したいオブジェクトを指定します。......Exception#exception を実行して変換を試みます。
//emlist[例][ruby]{
require "date"
def check_long_month(month)
return if Date.new(2000, month, -1).day == 31
raise "#{month} is not long month"
end
def get_exception
return begin
yield
rescue => e
e
end
end
results = [......get_exception { check_long_month(e) } }
p results.map { |e| e.class }
# => [RuntimeError, RuntimeError, RuntimeError]
p results.map { |e| e.message }
# => ["2 is not long month", "2 is not long month", "4 is not long month"]
# class, message, backtrace が同一のため true になる
p results[0... -
Float
# ==(other) -> bool (21237.0) -
比較演算子。数値として等しいか判定します。
...param other 比較対象の数値
@return self と other が等しい場合 true を返します。
そうでなければ false を返します。
//emlist[例][ruby]{
3.14 == 3.14000 # => true
3.14 == 3.1415 # => false
//}
NaNどうしの比較は、未定義です。
//emlist......[例][ruby]{
Float::NAN == Float::NAN # => false
[Float::NAN] == [Float::NAN] # => true
[Float::NAN] == [0.0 / 0.0] # => false
//}... -
Rational
# ==(other) -> bool (21237.0) -
数値として等しいか判定します。
...。
@param other 自身と比較する数値
@return self と other が等しい場合 true を返します。
そうでなければ false を返します。
//emlist[例][ruby]{
Rational(2, 3) == Rational(2, 3) # => true
Rational(5) == 5 # => true
Rational......(0) == 0.0 # => true
Rational('1/3') == 0.33 # => false
Rational('1/2') == '1/2' # => false
//}... -
Data
# ==(other) -> bool (21235.0) -
self と other のクラスが同じであり、各メンバが == メソッドで比較して等しい場合に true を返します。そうでない場合に false を返します。
...lf と other のクラスが同じであり、各メンバが == メソッドで比較して等しい場合に
true を返します。そうでない場合に false を返します。
@param other self と比較したいオブジェクトを指定します。
//emlist[例][ruby]{
Dog = Data.define......new("Fred", 5)
dog2 = Dog.new("Fred", 5.0)
p 5 == 5.0 # => true
p 5.eql?(5.0) # => false
p dog1 == dog2 # => true
p dog1.eql?(dog2) # => false
p dog1.equal?(dog2) # => false
//}
[注意] 本メソッドの記述は Data のサブクラスのインスタンスに対......して呼び
出す事を想定しています。Data.define は Data のサブクラスを作成する点に
注意してください。
@see Object#==, Data#eql?... -
Object
# ==(other) -> bool (21231.0) -
オブジェクトと other が等しければ真を返します。
...オブジェクトと other が等しければ真を返します。
このメソッドは各クラスの性質に合わせて再定義すべきです。
多くの場合、オブジェクトの内容が等しければ真を返すように
(同値性を判定するように)再定義されるこ......ます。
@param other 比較するオブジェクトです。
//emlist[例][ruby]{
o = Object.new
p(o.eql?(o)) #=> true
p(o.eql?(Object.new)) #=> false
//}
下記の例のように、各クラスの性質に合わせて再定義されることが期待されています。
//emlist[適切に再......定義されている例][ruby]{
p("foo" == "bar") #=> false
p("foo" == "foo") #=> true
p(4 == 4) #=> true
p(4 == 4.0) #=> true
//}
@see Object#equal?,Object#eql?... -
String
# ==(other) -> bool (21231.0) -
other が文字列の場合、String#eql? と同様に文字列の内容を比較します。
...other が文字列の場合、String#eql? と同様に文字列の内容を比較します。
other が文字列でない場合、
other.to_str が定義されていれば
other == self の結果を返します。(ただし、 other.to_str は実行されません。)
そうでなければ false......。
@param other 任意のオブジェクト
@return true か false
//emlist[例][ruby]{
stringlike = Object.new
def stringlike.==(other)
"string" == other
end
p "string".eql?(stringlike) #=> false
p "string" == stringlike #=> false
def stringlike.to_str
raise
end
p "string".......eql?(stringlike) #=> false
p "string" == stringlike #=> true
//}
@see String#eql?... -
Struct
# ==(other) -> bool (21229.0) -
self と other のクラスが同じであり、各メンバが == メソッドで比較して等しい場合に true を返します。そうでない場合に false を返します。
...f と other のクラスが同じであり、各メンバが == メソッドで比較して等しい場合に
true を返します。そうでない場合に false を返します。
@param other self と比較したいオブジェクトを指定します。
//emlist[例][ruby]{
Dog = Struct.new(:......, 5)
p dog1 == dog2 #=> true
p dog1.eql?(dog2) #=> true
p dog1.equal?(dog2) #=> false
//}
[注意] 本メソッドの記述は Struct の下位クラスのインスタンスに対して呼び
出す事を想定しています。Struct.new は Struct の下位......クラスを作成する点に
注意してください。
@see Struct#eql?... -
Pathname
# ==(other) -> bool (21225.0) -
パス名を比較し、 other と同じなら真を返します。大文字小文字は区別されます。 other は Pathname オブジェクトでなければなりません。
...パス名を比較し、 other と同じなら真を返します。大文字小文字は区別されます。
other は Pathname オブジェクトでなければなりません。
パス名の比較は単純にパス文字列の比較によって行われるので、論理的に
同じパスで......@param other 比較対象の 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")
# => true... -
BasicObject
# ==(other) -> bool (21219.0) -
オブジェクトが other と等しければ真を、そうでない場合は偽を返します。
...オブジェクトが other と等しければ真を、そうでない場合は偽を返します。
このメソッドは各クラスの性質に合わせて、サブクラスで再定義するべきです。
多くの場合、オブジェクトの内容が等しければ真を返すように (同......ルトでは Object#equal? と同じオブジェクトの同一性になっています。
@param other 比較対象となるオブジェクト
@return other が self と同値であれば真、そうでない場合は偽
//emlist[例][ruby]{
class Person < BasicObject
def initialize(name, age)......@name = name
@age = age
end
end
tanaka1 = Person.new("tanaka", 24)
tanaka2 = Person.new("tanaka", 24)
tanaka1 == tanaka1 #=> true
tanaka1 == tanaka2 #=> false
//}
@see BasicObject#equal?, Object#==, Object#equal?,
Object#eql?...