クラス
- Complex (11)
- Enumerator (1)
-
Enumerator
:: Chain (1) -
Enumerator
:: Lazy (7) - Float (44)
- Integer (7)
- NilClass (1)
- Numeric (17)
- Object (1)
-
Process
:: Tms (4) - Random (3)
- Range (5)
- Rational (8)
- String (5)
- Time (3)
モジュール
- Enumerable (1)
キーワード
- % (2)
- * (2)
- ** (3)
- + (2)
- -@ (2)
-
/ (3) - < (1)
- <= (1)
- <=> (1)
- == (1)
- > (1)
- >= (1)
- abs (2)
- angle (2)
- arg (2)
- bsearch (2)
- ceil (1)
- coerce (1)
- cstime (1)
- cutime (1)
- denominator (2)
- div (1)
- divmod (1)
- each (2)
-
enum
_ for (2) - eql? (1)
- fdiv (4)
- finite? (3)
- floor (1)
- grep (1)
-
grep
_ v (1) - hash (1)
- hex (1)
- infinite? (3)
- inspect (2)
- lazy (2)
- magnitude (2)
- modulo (1)
- nan? (1)
- negative? (1)
-
next
_ float (1) - numerator (2)
- oct (1)
- phase (2)
- positive? (1)
- pow (2)
-
prev
_ float (1) - quo (2)
- rand (3)
- rationalize (2)
- round (2)
-
singleton
_ class (1) - size (3)
- step (9)
- stime (1)
-
to
_ enum (2) -
to
_ f (7) -
to
_ i (2) -
to
_ r (1) -
to
_ s (2) - truncate (1)
- utime (1)
- zero? (1)
検索結果
先頭5件
-
Enumerator
:: Lazy # grep(pattern) {|item| . . . } -> Enumerator :: Lazy (346.0) -
Enumerable#grep と同じですが、配列ではなくEnumerator::Lazy を返します。
Enumerable#grep と同じですが、配列ではなくEnumerator::Lazy を返します。
//emlist[例][ruby]{
(100..Float::INFINITY).lazy.map(&:to_s).grep(/\A(\d)\1+\z/)
# => #<Enumerator::Lazy: #<Enumerator::Lazy: #<Enumerator::Lazy: 100..Infinity>:map>:grep(/\A(\d)\1+\z/)>
(100..Float::INFINITY).lazy.map(&:to_s).grep(/\A(\d)\1+\z/).... -
Enumerator
:: Lazy # grep _ v(pattern) {|item| . . . } -> Enumerator :: Lazy (346.0) -
Enumerable#grep_v と同じですが、配列ではなくEnumerator::Lazy を返します。
Enumerable#grep_v と同じですが、配列ではなくEnumerator::Lazy を返します。
//emlist[例][ruby]{
(100..Float::INFINITY).lazy.map(&:to_s).grep_v(/(\d).*\1/)
# => #<Enumerator::Lazy: #<Enumerator::Lazy: #<Enumerator::Lazy: 100..Infinity>:map>:grep_v(/(\d).*\1/)>
(100..Float::INFINITY).lazy.map(&:to_s).grep_v(/(\d).*\1/).t... -
Integer
# div(other) -> Integer (346.0) -
整商(整数の商)を返します。 普通の商(剰余を考えない商)を越えない最大の整数をもって整商とします。
整商(整数の商)を返します。
普通の商(剰余を考えない商)を越えない最大の整数をもって整商とします。
other が Integer オブジェクトの場合、Integer#/ の結果と一致します。
div に対応する剰余メソッドは modulo です。
@param other 二項演算の右側の引数(対象)
@return 計算結果
//emlist[例][ruby]{
7.div(2) # => 3
7.div(-2) # => -4
7.div(2.0) # => 3
7.div(Rational(2, 1)) # => 3
begin
2.div(0)
rescue => ... -
Numeric
# finite? -> bool (346.0) -
self の絶対値が有限値の場合に true を、そうでない場合に false を返します。
self の絶対値が有限値の場合に true を、そうでない場合に false を返します。
//emlist[例][ruby]{
10.finite? # => true
Rational(3).finite? # => true
Float::INFINITY.finite? # => false
Float::INFINITY.is_a?(Numeric) # => true
//}
@see Numeric#infinite? -
Complex
# abs -> Numeric (328.0) -
自身の絶対値を返します。
自身の絶対値を返します。
以下の計算の結果を Float オブジェクトで返します。
sqrt(self.real ** 2 + self.imag ** 2)
//emlist[例][ruby]{
Complex(1, 2).abs # => 2.23606797749979
Complex(3, 4).abs # => 5.0
Complex('1/2', '1/2').abs # => 0.7071067811865476
//}
@see Complex#abs2 -
Complex
# finite? -> bool (328.0) -
実部と虚部の両方が有限値の場合に true を、そうでない場合に false を返します。
実部と虚部の両方が有限値の場合に true を、そうでない場合に false を返します。
//emlist[例][ruby]{
(1 + 1i).finite? # => true
(Float::INFINITY + 1i).finite? # => false
//}
@see Complex#infinite? -
Complex
# infinite? -> nil | 1 (328.0) -
実部と虚部のどちらも無限大ではない場合に nil を、そうでない場合に 1 を返します。
実部と虚部のどちらも無限大ではない場合に nil を、そうでない場合に 1 を返します。
//emlist[例][ruby]{
(1+1i).infinite? # => nil
(Float::INFINITY + 1i).infinite? # => 1
//}
@see Complex#finite? -
Complex
# magnitude -> Numeric (328.0) -
自身の絶対値を返します。
自身の絶対値を返します。
以下の計算の結果を Float オブジェクトで返します。
sqrt(self.real ** 2 + self.imag ** 2)
//emlist[例][ruby]{
Complex(1, 2).abs # => 2.23606797749979
Complex(3, 4).abs # => 5.0
Complex('1/2', '1/2').abs # => 0.7071067811865476
//}
@see Complex#abs2 -
Enumerable
# lazy -> Enumerator :: Lazy (328.0) -
自身を lazy な Enumerator に変換したものを返します。
自身を lazy な Enumerator に変換したものを返します。
この Enumerator は、以下のメソッドが遅延評価を行う (つまり、配列ではな
くEnumeratorを返す) ように再定義されています。
* map/collect
* flat_map/collect_concat
* select/find_all
* reject
* grep
* take, take_while
* drop, drop_while
* zip (※一貫性のため、ブロックを渡さないケースのみlazy)
* cycle (※一貫性のため、ブロックを渡さないケースのみl... -
Enumerator
:: Lazy # enum _ for(method = :each , *args) -> Enumerator :: Lazy (328.0) -
Object#to_enum と同じですが、Enumerator::Lazy を返します。
Object#to_enum と同じですが、Enumerator::Lazy を返します。
to_enum は「ブロック付きで呼ぶとループを実行し、ブロックを省略した場合は
Enumerator を返す」ようなメソッドを定義するときによく使われます。
このときに lazy 性が正しく引き継がれるように、Lazy#to_enum は
素のEnumerator ではなく Enumerator::Lazy を返すようになっています。
//emlist[例][ruby]{
module Enumerable
# 要素をn回ずつ繰り返すメソッド
# 例:[1,2,3].repeat(2) ... -
Enumerator
:: Lazy # enum _ for(method = :each , *args) {|*args| block} -> Enumerator :: Lazy (328.0) -
Object#to_enum と同じですが、Enumerator::Lazy を返します。
Object#to_enum と同じですが、Enumerator::Lazy を返します。
to_enum は「ブロック付きで呼ぶとループを実行し、ブロックを省略した場合は
Enumerator を返す」ようなメソッドを定義するときによく使われます。
このときに lazy 性が正しく引き継がれるように、Lazy#to_enum は
素のEnumerator ではなく Enumerator::Lazy を返すようになっています。
//emlist[例][ruby]{
module Enumerable
# 要素をn回ずつ繰り返すメソッド
# 例:[1,2,3].repeat(2) ... -
Enumerator
:: Lazy # lazy -> self (328.0) -
self を返します。
self を返します。
//emlist[例][ruby]{
lazy = (100..Float::INFINITY).lazy
p lazy.lazy # => #<Enumerator::Lazy: 100..Infinity>
p lazy == lazy.lazy # => true
//} -
Enumerator
:: Lazy # to _ enum(method = :each , *args) -> Enumerator :: Lazy (328.0) -
Object#to_enum と同じですが、Enumerator::Lazy を返します。
Object#to_enum と同じですが、Enumerator::Lazy を返します。
to_enum は「ブロック付きで呼ぶとループを実行し、ブロックを省略した場合は
Enumerator を返す」ようなメソッドを定義するときによく使われます。
このときに lazy 性が正しく引き継がれるように、Lazy#to_enum は
素のEnumerator ではなく Enumerator::Lazy を返すようになっています。
//emlist[例][ruby]{
module Enumerable
# 要素をn回ずつ繰り返すメソッド
# 例:[1,2,3].repeat(2) ... -
Enumerator
:: Lazy # to _ enum(method = :each , *args) {|*args| block} -> Enumerator :: Lazy (328.0) -
Object#to_enum と同じですが、Enumerator::Lazy を返します。
Object#to_enum と同じですが、Enumerator::Lazy を返します。
to_enum は「ブロック付きで呼ぶとループを実行し、ブロックを省略した場合は
Enumerator を返す」ようなメソッドを定義するときによく使われます。
このときに lazy 性が正しく引き継がれるように、Lazy#to_enum は
素のEnumerator ではなく Enumerator::Lazy を返すようになっています。
//emlist[例][ruby]{
module Enumerable
# 要素をn回ずつ繰り返すメソッド
# 例:[1,2,3].repeat(2) ... -
Numeric
# denominator -> Integer (328.0) -
自身を Rational に変換した時の分母を返します。
自身を Rational に変換した時の分母を返します。
@return 分母を返します。
@see Numeric#numerator、Integer#denominator、Float#denominator、Rational#denominator、Complex#denominator -
Numeric
# numerator -> Integer (328.0) -
自身を Rational に変換した時の分子を返します。
自身を Rational に変換した時の分子を返します。
@return 分子を返します。
@see Numeric#denominator、Integer#numerator、Float#numerator、Rational#numerator、Complex#numerator -
Object
# singleton _ class -> Class (328.0) -
レシーバの特異クラスを返します。 まだ特異クラスがなければ、新しく作成します。
レシーバの特異クラスを返します。
まだ特異クラスがなければ、新しく作成します。
レシーバが nil か true か false なら、それぞれ NilClass, TrueClass,
FalseClass を返します。
@raise TypeError レシーバが Integer、Float、Symbol の場合に発生します。
//emlist[][ruby]{
Object.new.singleton_class #=> #<Class:#<Object:0xb7ce1e24>>
String.singleton_class #=> #<Class:String>
n... -
Range
# each -> Enumerator (328.0) -
範囲内の要素に対して繰り返します。
範囲内の要素に対して繰り返します。
Range#each は各要素の succ メソッドを使用してイテレーションするようになりました。
@raise TypeError succ メソッドを持たないクラスの範囲オブジェクトに対してこのメソッドを呼んだ場合に発生します。
//emlist[例][ruby]{
(10..15).each {|n| print n, ' ' }
# prints: 10 11 12 13 14 15
(2.5..5).each {|n| print n, ' ' }
# raises: TypeError: can't iterate from Floa... -
Range
# each {|item| . . . } -> self (328.0) -
範囲内の要素に対して繰り返します。
範囲内の要素に対して繰り返します。
Range#each は各要素の succ メソッドを使用してイテレーションするようになりました。
@raise TypeError succ メソッドを持たないクラスの範囲オブジェクトに対してこのメソッドを呼んだ場合に発生します。
//emlist[例][ruby]{
(10..15).each {|n| print n, ' ' }
# prints: 10 11 12 13 14 15
(2.5..5).each {|n| print n, ' ' }
# raises: TypeError: can't iterate from Floa...