別のキーワード
種類
- インスタンスメソッド (112)
- 文書 (22)
ライブラリ
- ビルトイン (111)
-
minitest
/ unit (1)
モジュール
- Comparable (22)
- Enumerable (29)
-
MiniTest
:: Assertions (1)
キーワード
-
assert
_ in _ epsilon (1) - between? (11)
- bsearch (22)
-
bsearch
_ index (9) - none? (47)
- 制御構造 (11)
- 正規表現 (11)
検索結果
先頭5件
-
Module
# >=(other) -> bool | nil (27549.0) -
比較演算子。self が other の先祖か同一クラスである場合、 true を返します。 self が other の子孫である場合、false を返します。
...比較演算子。self が other の先祖か同一クラスである場合、 true を返します。
self が other の子孫である場合、false を返します。
継承関係にないクラス同士の比較では
nil を返します。
@param other 比較対象のモジュールやクラ......Module#<
//emlist[例][ruby]{
module Foo; end
module Bar
include Foo
end
module Baz
prepend Foo
end
Bar.ancestors # => [Bar, Foo]
Foo >= Bar # => true
Bar >= Foo # => false
Baz.ancestors # => [Foo, Baz]
Foo >= Baz # => true
Baz >= Foo # => false
Foo >= Foo # => true
Foo >= Object # => nil
//... -
Comparable
# >=(other) -> bool (27324.0) -
比較演算子 <=> をもとにオブジェクト同士を比較します。 <=> が正の整数か 0 を返した場合に、true を返します。 それ以外の整数を返した場合に、false を返します。
...比較演算子 <=> をもとにオブジェクト同士を比較します。
<=> が正の整数か 0 を返した場合に、true を返します。
それ以外の整数を返した場合に、false を返します。
@param other 自身と比較したいオブジェクトを指定します。......@raise ArgumentError <=> が nil を返したときに発生します。
//emlist[例][ruby]{
1 >= 0 # => true
1 >= 1 # => true
1 >= 2 # => false
//}... -
MiniTest
:: Assertions # assert _ in _ epsilon(actual , expected , epsilon = 0 . 001 , message = nil) -> true (6407.0) -
与えられた期待値と実際の値の相対誤差が許容範囲内である場合、検査にパスしたことになります。
...が真である場合、検査をパスします。
[expected, actual].min * epsilon >= (extected - actual).abs
@param expected 期待値を指定します。
@param actual 実際の値を指定します。
@param epsilon 許容する相対誤差を指定します。
@param message 検査に......失敗した場合に表示するメッセージを指定します。
文字列か Proc を指定します。Proc である場合は Proc#call した
結果を使用します。
@raise MiniTest::Assertion 検査に失敗した場合に発生します。... -
Enumerable
# none? -> bool (3224.0) -
ブロックを指定しない場合は、 Enumerable オブジェクトのすべての 要素が偽であれば真を返します。そうでなければ偽を返します。
...ブロックを指定しない場合は、 Enumerable オブジェクトのすべての
要素が偽であれば真を返します。そうでなければ偽を返します。
ブロックを指定した場合は、Enumerable オブジェクトのすべての要素を
ブロックで評価した結......e を返します。
//emlist[例][ruby]{
require 'set'
Set['ant', 'bear', 'cat'].none? {|word| word.length == 5} # => true
Set['ant', 'bear', 'cat'].none? {|word| word.length >= 4} # => false
Set[].none? # => true
Set[nil].none?......# => true
Set[nil,false].none? # => true
Set[nil, false, true].none? # => false
//}......= item を評価します。
//emlist[例][ruby]{
require 'set'
Set['ant', 'bear', 'cat'].none? {|word| word.length == 5} # => true
Set['ant', 'bear', 'cat'].none? {|word| word.length >= 4} # => false
Set['ant', 'bear', 'cat'].none?(/d/) # => true
Set[].none?......# => true
Set[nil].none? # => true
Set[nil,false].none? # => true
Set[nil, false, true].none? # => false
//}......# => true
Set[nil].none? # => true
Set[nil,false].none? # => true
Set[nil, false, true].none? # => false
//}
@see Array#none?... -
Enumerable
# none? {|obj| . . . } -> bool (3224.0) -
ブロックを指定しない場合は、 Enumerable オブジェクトのすべての 要素が偽であれば真を返します。そうでなければ偽を返します。
...ブロックを指定しない場合は、 Enumerable オブジェクトのすべての
要素が偽であれば真を返します。そうでなければ偽を返します。
ブロックを指定した場合は、Enumerable オブジェクトのすべての要素を
ブロックで評価した結......e を返します。
//emlist[例][ruby]{
require 'set'
Set['ant', 'bear', 'cat'].none? {|word| word.length == 5} # => true
Set['ant', 'bear', 'cat'].none? {|word| word.length >= 4} # => false
Set[].none? # => true
Set[nil].none?......# => true
Set[nil,false].none? # => true
Set[nil, false, true].none? # => false
//}......= item を評価します。
//emlist[例][ruby]{
require 'set'
Set['ant', 'bear', 'cat'].none? {|word| word.length == 5} # => true
Set['ant', 'bear', 'cat'].none? {|word| word.length >= 4} # => false
Set['ant', 'bear', 'cat'].none?(/d/) # => true
Set[].none?......# => true
Set[nil].none? # => true
Set[nil,false].none? # => true
Set[nil, false, true].none? # => false
//}......# => true
Set[nil].none? # => true
Set[nil,false].none? # => true
Set[nil, false, true].none? # => false
//}
@see Array#none?... -
Enumerable
# none?(pattern) -> bool (3224.0) -
ブロックを指定しない場合は、 Enumerable オブジェクトのすべての 要素が偽であれば真を返します。そうでなければ偽を返します。
...ブロックを指定しない場合は、 Enumerable オブジェクトのすべての
要素が偽であれば真を返します。そうでなければ偽を返します。
ブロックを指定した場合は、Enumerable オブジェクトのすべての要素を
ブロックで評価した結......= item を評価します。
//emlist[例][ruby]{
require 'set'
Set['ant', 'bear', 'cat'].none? {|word| word.length == 5} # => true
Set['ant', 'bear', 'cat'].none? {|word| word.length >= 4} # => false
Set['ant', 'bear', 'cat'].none?(/d/) # => true
Set[].none?......# => true
Set[nil].none? # => true
Set[nil,false].none? # => true
Set[nil, false, true].none? # => false
//}......# => true
Set[nil].none? # => true
Set[nil,false].none? # => true
Set[nil, false, true].none? # => false
//}
@see Array#none?... -
Comparable
# between?(min , max) -> bool (3212.0) -
比較演算子 <=> をもとに self が min と max の範囲内(min, max を含みます)にあるかを判断します。
...比較演算子 <=> をもとに self が min と max の範囲内(min, max
を含みます)にあるかを判断します。
以下のコードと同じです。
//emlist[][ruby]{
self >= min and self <= max
//}
@param min 範囲の下端を表すオブジェクトを指定します。
@param m......Error self <=> min か、self <=> max が nil を返
したときに発生します。
//emlist[例][ruby]{
3.between?(1, 5) # => true
6.between?(1, 5) # => false
'cat'.between?('ant', 'dog') # => true
'gnu'.between?('ant', 'dog') # => false
//}... -
制御構造 (3126.0)
-
制御構造 条件分岐: * if * unless * case 繰り返し: * while * until * for * break * next * redo * retry 例外処理: * raise * begin その他: * return * BEGIN * END
...制御構造
条件分岐:
* if
* unless
* case
繰り返し:
* while
* until
* for
* break
* next
* redo
* retry
例外処理:
* raise
* begin
その他:
* return
* BEGIN
* END
Rubyでは(Cなどとは異なり)制御構造は式であ......call#blockという
制御構造の抽象化を援助する機能があります。ブロック付きメソッド呼び出しは
繰り返しを始めとする制御構造をクラス設計者が定義する事が出来るものです.
=== 条件分岐
====[a:if] if
//emlist[例][ruby]{
if age >=......および elsif
の条件式が偽であったとき else 節があればその式が評価されます。
if 式は、条件が成立した節(あるいは else 節)の最後に評価し
た式の結果を返します。else 節がなくいずれの条件も成り立たなけれ
ば nil を返し... -
正規表現 (768.0)
-
正規表現 * metachar * expansion * char * anychar * string * str * quantifier * capture * grouping * subexp * selector * anchor * cond * option * encoding * comment * free_format_mode * absenceop * list * specialvar * references
...string
* str
* quantifier
* capture
* grouping
* subexp
* selector
* anchor
* cond
* option
* encoding
* comment
* free_format_mode
* absenceop
* list
* specialvar
* references
正規表現(regular expression)は文字列のパターンを記述するための言語......ことが
できます。
//emlist[][ruby]{
place = "東京都"
/#{place}/.match("Go to 東京都") # => #<MatchData "東京都">
//}
埋め込んだ文字列にメタ文字が含まれているならば、それは
メタ文字として認識されます。
//emlist[][ruby]{
number = "(\\d+)"
op......emlist[][ruby]{
/[a-z[0-9]]/.match("y") # => #<MatchData "y">
/[a-z[0-9]]/.match("[") # => nil
r = /[a-w&&[^c-g]e]/ # ([a-w] かつ ([^c-g] もしくは e)) つまり [abeh-w] と同じ
r.match("b") # => #<MatchData "b">
r.match("c") # => nil
r.match("e") # => #<MatchData "e">
r.match("g") # => nil... -
Range
# bsearch {|obj| . . . } -> object | nil (383.0) -
ブロックの評価結果で範囲内の各要素の大小判定を行い、条件を満たす値を二 分探索(計算量は O(log n))で検索します。要素が見つからない場合は nil を 返します。
...評価結果で範囲内の各要素の大小判定を行い、条件を満たす値を二
分探索(計算量は O(log n))で検索します。要素が見つからない場合は nil を
返します。
本メソッドはブロックを評価した結果により以下のいずれかのモード......false を返す
ブロックの評価結果が true になる最初の要素を返すか、nil を返します。
//emlist[例][ruby]{
ary = [0, 4, 7, 10, 12]
(0...ary.size).bsearch {|i| ary[i] >= 4 } # => 1
(0...ary.size).bsearch {|i| ary[i] >= 6 } # => 2
(0...ary.size).bsearch {|i| ary[i] >= 8......} # => 3
(0...ary.size).bsearch {|i| ary[i] >= 100 } # => nil
(0.0...Float::INFINITY).bsearch {|x| Math.log(x) >= 0 } # => 1.0
//}
find-any モードは bsearch(3) のように動作します。ブロックは真偽値
ではなく、以下のような数値を返す必要があります。求め... -
Array
# bsearch { |x| . . . } -> object | nil (371.0) -
ブロックの評価結果で範囲内の各要素の判定を行い、条件を満たす値を二分探 索(計算量は O(log n))で検索します。要素が見つからない場合は nil を返し ます。self はあらかじめソートしておく必要があります。
...結果で範囲内の各要素の判定を行い、条件を満たす値を二分探
索(計算量は O(log n))で検索します。要素が見つからない場合は nil を返し
ます。self はあらかじめソートしておく必要があります。
本メソッドはブロックを評......lse を返す
ブロックの評価結果が true になる最初の要素を返すか、nil を返します。
//emlist[例][ruby]{
ary = [0, 4, 7, 10, 12]
ary.bsearch {|x| x >= 4 } # => 4
ary.bsearch {|x| x >= 6 } # => 7
ary.bsearch {|x| x >= -1 } # => 0
ary.bsearch {|x| x >= 100 } # => nil......きい(j <= k < self.size)場合: 負の数を返す
ブロックの評価結果が 0 になるいずれかの要素を返すか、nil を返します。
//emlist[例][ruby]{
ary = [0, 4, 7, 10, 12]
# 4 <= v < 8 になる要素を検索
ary.bsearch {|x| 1 - x / 4 } # => 4 or 7
# 8 <= v < 10...