ライブラリ
クラス
-
ARGF
. class (77) - Array (19)
- BasicObject (22)
- Binding (11)
- Coverage (6)
- Data (4)
-
Enumerator
:: ArithmeticSequence (6) - Exception (22)
- File (11)
- Object (11)
- Prime (22)
- Proc (11)
-
Rake
:: FileList (11) - Regexp (11)
-
RubyVM
:: InstructionSequence (22) - Set (22)
- String (55)
- Thread (11)
- WIN32OLE (11)
-
WIN32OLE
_ TYPE (11) -
Zlib
:: GzipReader (11)
モジュール
- Enumerable (66)
- Kernel (11)
- ObjectSpace (11)
-
Process
:: GID (22) -
Process
:: UID (22) - Readline (11)
オブジェクト
- ENV (22)
キーワード
- != (11)
-
$ CHILD _ STATUS (11) -
1
. 6 . 8から1 . 8 . 0への変更点(まとめ) (11) - === (33)
- ConditionVariable (11)
- Continuation (11)
- Marshal フォーマット (11)
-
NEWS for Ruby 2
. 1 . 0 (11) -
NEWS for Ruby 2
. 7 . 0 (5) -
NEWS for Ruby 3
. 0 . 0 (4) - NKF (11)
- Numeric (11)
- Ruby用語集 (11)
- String (11)
-
backtrace
_ locations (11) - bigdecimal (11)
- crypt (11)
-
default
_ event _ sources (11) - define (4)
- disasm (11)
- disassemble (11)
- divide (22)
- each (55)
-
each
_ line (44) -
each
_ pair (22) - fiddle (11)
-
fiddle
/ types (11) -
line
_ stub (6) - lineno= (11)
-
local
_ variable _ defined? (11) - lstat (11)
- max (22)
-
memsize
_ of _ all (11) - min (44)
-
net
/ pop (11) -
ole
_ func _ methods (11) - pack (19)
- pack テンプレート文字列 (11)
-
pending
_ interrupt? (11) - rdoc (11)
- readline (11)
-
rinda
/ rinda (11) -
ruby 1
. 6 feature (11) -
ruby 1
. 8 . 2 feature (11) -
ruby 1
. 8 . 3 feature (11) -
ruby 1
. 8 . 4 feature (11) -
ruby 1
. 9 feature (11) - sum (11)
- switch (44)
- tracer (11)
- tsort (11)
- unpack (11)
-
webrick
/ cgi (11) - yield (11)
- 制御構造 (11)
- 演算子式 (11)
検索結果
先頭5件
-
Exception
# ==(other) -> bool (21152.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......ception { 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] == re... -
String
# ==(other) -> bool (21136.0) -
other が文字列の場合、String#eql? と同様に文字列の内容を比較します。
...other が文字列の場合、String#eql? と同様に文字列の内容を比較します。
other が文字列でない場合、
other.to_str が定義されていれば
other == self の結果を返します。(ただし、 other.to_str は実行されません。)
そうでなければ 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#e... -
BasicObject
# ==(other) -> bool (21124.0) -
オブジェクトが other と等しければ真を、さもなくば偽を返します。
...//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#==, Obje... -
Enumerator
:: ArithmeticSequence # ==(other) -> bool (21112.0) -
Enumerable::ArithmeticSequence として等しいか判定します。
...Enumerable::ArithmeticSequence として等しいか判定します。
other が Enumerable::ArithmeticSequence で
begin, end, step, exclude_end? が等しい時に
true を返します。
@param other 自身と比較する Enumerable::ArithmeticSequence... -
Rake
:: FileList # ==(array) -> bool (21112.0) -
自身を配列に変換してから与えられた配列と比較します。
...列と比較します。
@param array 比較対象の配列を指定します。
//emlist[][ruby]{
# Rakefile での記載例とする
task default: :test_rake_app
task :test_rake_app do
file_list = FileList.new('lib/**/*.rb', 'test/test*.rb')
file_list == file_list.to_a # => true
end
//}... -
Thread
. pending _ interrupt?(error = nil) -> bool (18330.0) -
非同期割り込みのキューが空かどうかを返します。
...Thread.handle_interrupt は非同期割り込みの発生を延期させるのに使
用しますが、本メソッドは任意の非同期割り込みが存在するかどうかを確認す
るのに使用します。
本メソッドが true を返した場合、Thread.handle_interrupt で例外......だちに発生させる。
def Thread.kick_interrupt_immediately
Thread.handle_interrupt(Object => :immediate) {
Thread.pass
}
end
=== 使い方
th = Thread.new{
Thread.handle_interrupt(RuntimeError => :on_blocking){
while true
...
# ここまでで......
if Thread.pending_interrupt?
Thread.handle_interrupt(Object => :immediate){}
end
...
end
}
}
...
th.raise # スレッド停止。
この例は以下のように記述する事もできます。
flag = true
th = Thread.new{
Thread.handle_in... -
Regexp
# ===(string) -> bool (12306.0) -
文字列 string との正規表現マッチを行います。 マッチした場合は真を返します。
...文字列 string との正規表現マッチを行います。
マッチした場合は真を返します。
string が文字列でもシンボルでもない場合には false を返します。
このメソッドは主にcase文での比較に用いられます。
@param string マッチ対象......文字列
//emlist[例][ruby]{
a = "HELLO"
case a
when /\A[a-z]*\z/; puts "Lower case"
when /\A[A-Z]*\z/; puts "Upper case"
else; puts "Mixed case"
end
# => Upper case
/\A[a-z]*\z/ === "HELLO" # => false
/\A[A-Z]*\z/ === "HELLO" # => true
//}
@see Enumerable#grep, Object#===... -
String
# ===(other) -> bool (12236.0) -
other が文字列の場合、String#eql? と同様に文字列の内容を比較します。
...other が文字列の場合、String#eql? と同様に文字列の内容を比較します。
other が文字列でない場合、
other.to_str が定義されていれば
other == self の結果を返します。(ただし、 other.to_str は実行されません。)
そうでなければ 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#e... -
Object
# ===(other) -> bool (12224.0) -
case 式で使用されるメソッドです。d:spec/control#case も参照してください。
...bject#== を呼び出します。
when 節の式をレシーバーとして === を呼び出すことに注意してください。
また Enumerable#grep でも使用されます。
@param other 比較するオブジェクトです。
//emlist[][ruby]{
age = 12
# (0..2).===(12), (3..6).===(12),......6
"little child"
when 7 .. 12
"child"
when 13 .. 18
"youth"
else
"adult"
end
puts result #=> "child"
def check arg
case arg
when /ruby(?!\s*on\s*rails)/i
"hit! #{arg}"
when String
"Instance of String class. But don't hit."
else
"unknown"
end
end
puts......check([]) #=> unknown
puts check("mash-up in Ruby on Rails") #=> instance of String class. But not hit...
puts check("<Ruby's world>") #=> hit! <Ruby's world>
//}
@see Object#==, Range#===, Module#===, Regexp#===, Enumerable#grep... -
Binding
# local _ variable _ defined?(symbol) -> bool (12112.0) -
引数 symbol で指定した名前のローカル変数が定義されている場合に true を、 そうでない場合に false を返します。
...//emlist[例][ruby]{
def foo
a = 1
binding.local_variable_defined?(:a) # => true
binding.local_variable_defined?(:b) # => false
end
//}
このメソッドは以下のコードの短縮形です。
//emlist[][ruby]{
binding.eval("defined?(#{symbol}) == 'local-variable'")
//}
@see Binding#lo......cal_variable_get, Binding#local_variable_set...