るりまサーチ

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

別のキーワード

  1. openssl integer
  2. asn1 integer
  3. _builtin integer
  4. integer new
  5. integer digits

ライブラリ

キーワード

検索結果

<< 1 2 3 ... > >>

Integer#div(other) -> Integer (21150.0)

整商(整数の商)を返します。 普通の商(剰余を考えない商)を越えない最大の整数をもって整商とします。

...ます。
普通の商(剰余を考えない商)を越えない最大の整数をもって整商とします。

other が Integer オブジェクトの場合、Integer#/ の結果と一致します。

div に対応する剰余メソッドは modulo です。

@param other 二項演算の右側...
...# => 3

begin

2.div(0)
rescue => e
e # => #<ZeroDivisionError: divided by 0>
end

begin

2.div(0.0)
rescue => e
e # => #<ZeroDivisionError: divided by 0>
# Integer#/ と違い、引数が Float でもゼロで割ることはできない
end
//}

@see Integer#fdiv, Integer#/, Integer#modulo...

Integer#/(other) -> Numeric (21031.0)

除算の算術演算子。

...除算の算術演算子。

other が Integer の場合、整商(整数の商)を Integer で返します。
普通の商(剰余を考えない商)を越えない最大の整数をもって整商とします。

other が Float、Rational、Complex の場合、普通の商を other と
...
...側の引数(対象)
@return 計算結果

//emlist[例][ruby]{
7 / 2 # => 3
7 / -2 # => -4
7 / 2.0 # => 3.5
7 / Rational(2, 1) # => (7/2)
7 / Complex(2, 0) # => ((7/2)+0i)

begin

2 / 0
rescue => e
e # => #<ZeroDivisionError: divided by 0>
end
//}

@see Integer#div, Integer#fdiv, Numeric#quo...

MatchData#begin(n) -> Integer | nil (18239.0)

n 番目の部分文字列先頭のオフセットを返します。

...範囲外の n を指定した場合に発生します。

//emlist[例][ruby]{
/(foo)(bar)(BAZ)?/ =~ "foobarbaz"
p $~.begin(0) # => 0
p $~.begin(1) # => 0
p $~.begin(2) # => 3
p $~.begin(3) # => nil
p $~.begin(4) # => `begin': index 4 out of matches (IndexError)
//}

@see MatchData#end...

MatchData#offset(n) -> [Integer, Integer] | [nil, nil] (219.0)

n 番目の部分文字列のオフセットの配列 [start, end] を返 します。

...]{
[ self.begin(n), self.end(n) ]
//}

と同じです。n番目の部分文字列がマッチしていなければ
[nil, nil] を返します。

@param n 部分文字列を指定する数値

@raise IndexError 範囲外の n を指定した場合に発生します。

@see MatchData#begin, MatchDa...

MatchData#offset(name) -> [Integer, Integer] | [nil, nil] (219.0)

name という名前付きグループに対応する部分文字列のオフセットの配列 [start, end] を返 します。

...う名前付きグループに対応する部分文字列のオフセットの配列 [start, end] を返
します。

//emlist[例][ruby]{
[ self.begin(name), self.end(name) ]
//}

と同じです。nameの名前付きグループにマッチした部分文字列がなければ
[nil, nil] を返し...
...('year') # => [0, 4]
p $~.offset(:year) # => [0, 4]
p $~.offset('month') # => [5, 6]
p $~.offset(:month) # => [5, 6]
p $~.offset('day') # => [nil, nil]
p $~.offset('century') # => `offset': undefined group name reference: century (IndexError)
//}

@see MatchData#begin, MatchData#end...
...0, 4]
p $~.offset(:year) # => [0, 4]
p $~.offset('month') # => [5, 6]
p $~.offset(:month) # => [5, 6]
p $~.offset('day') # => [nil, nil]
p $~.offset('century') # => `offset': undefined group name reference: century (IndexError)
//}

@see MatchData#begin, MatchData#end, MatchData#offset...

絞り込み条件を変える

BasicSocket#getpeereid -> [Integer, Integer] (209.0)

Unix ドメインソケットにおいて接続相手の euid と egid を 返します。

...が Unix ドメインソケットでない場合の返り値は
不定です。

require 'socket'

Socket.unix_server_loop("/tmp/sock") {|s|
begin

euid, egid = s.getpeereid

# Check the connected client is myself or not.
next if euid != Process.uid

# do s...

Random#rand(max) -> Integer | Float (139.0)

一様な擬似乱数を発生させます。

...範囲から除かれます。
range.end - range.begin が整数を返す場合は range.begin + self.rand((range.end - range.begin) + e)
の値を返します(e は終端を含む場合は1、含まない場合は0です)。
range.end - range.begin が実数を返す場合も同様です。
この...
...ge 発生させる乱数値の範囲を Range オブジェクトで指定します。
range.end - range.begin は数値である必要があり、
range.begin + 数値 が適切な値を返す必要があります。

@raise Errno::EDOM rand(1..Float::INFINITY) などのよ...

Random#rand(range) -> Integer | Float (139.0)

一様な擬似乱数を発生させます。

...範囲から除かれます。
range.end - range.begin が整数を返す場合は range.begin + self.rand((range.end - range.begin) + e)
の値を返します(e は終端を含む場合は1、含まない場合は0です)。
range.end - range.begin が実数を返す場合も同様です。
この...
...ge 発生させる乱数値の範囲を Range オブジェクトで指定します。
range.end - range.begin は数値である必要があり、
range.begin + 数値 が適切な値を返す必要があります。

@raise Errno::EDOM rand(1..Float::INFINITY) などのよ...

SystemCallError#errno -> Integer | nil (114.0)

レシーバに対応するシステム依存のエラーコードを返します。

...ドを渡さない形式で生成した場合は nil を返します。

begin

raise Errno::ENOENT
rescue Errno::ENOENT => err
p err.errno # => 2
p Errno::ENOENT::Errno # => 2
end

begin

raise SystemCallError, 'message'
rescue SystemCallError => err...
<< 1 2 3 ... > >>