種類
- インスタンスメソッド (72)
- 特異メソッド (1)
検索結果
先頭5件
-
Integer
# chr -> String (3) -
与えられたエンコーディング encoding において self を文字コードと見た時、それに対応する一文字からなる文字列を返します。 引数無しで呼ばれた場合は self を US-ASCII、ASCII-8BIT、デフォルト内部エンコーディングの順で優先的に解釈します。
文字コードに対応する 1 バイトの文字列を返します。
例えば65.chr は "A" を返します。
逆に文字列から文字コードを得るには "A"[0] とします
@return 1バイト文字列
@raise RangeError self が 0 から 255 の範囲外の場合に発生します。
@see String#[]与えられたエンコーディング encoding において self を文字コードと見た時、それに対応する一文字からなる文字列を返します。
引数無しで呼ばれた場合は self を US-ASCII、ASCII-8BIT、デフォルト内部エンコーディングの順で優先的に解釈します。
p 65.chr # => "A"
p 0x79.chr.encoding # => #<Encoding:US_ASCII>
p 0x80.chr.encoding # => #<Encoding:ASCII_8BIT>
p 12354.chr Encoding::UTF_8 # => "あ"
p ... -
Integer
# chr(encoding) -> String (3) -
与えられたエンコーディング encoding において self を文字コードと見た時、それに対応する一文字からなる文字列を返します。 引数無しで呼ばれた場合は self を US-ASCII、ASCII-8BIT、デフォルト内部エンコーディングの順で優先的に解釈します。
与えられたエンコーディング encoding において self を文字コードと見た時、それに対応する一文字からなる文字列を返します。
引数無しで呼ばれた場合は self を US-ASCII、ASCII-8BIT、デフォルト内部エンコーディングの順で優先的に解釈します。
p 65.chr # => "A"
p 0x79.chr.encoding # => #<Encoding:US_ASCII>
p 0x80.chr.encoding # => #<Encoding:ASCII_8BIT>
p 12354.chr Encoding::UTF_8 # => "あ"
p ... -
Integer
# denominator -> Integer (3) -
分母(常に1)を返します。
...分母(常に1)を返します。
@return 分母を返します。
@see Integer#numerator... -
Integer
# downto(min) -> Enumerable :: Enumerator (3) -
self から min まで 1 ずつ減らしながらブロックを繰り返し実行します。 self < min であれば何もしません。
...し実行します。
self < min であれば何もしません。
@param min 数値
@return self を返します。
@see Integer#upto, Numeric#step, Integer#times... -
Integer
# downto(min) -> Enumerator (3) -
self から min まで 1 ずつ減らしながらブロックを繰り返し実行します。 self < min であれば何もしません。
...し実行します。
self < min であれば何もしません。
@param min 数値
@return self を返します。
@see Integer#upto, Numeric#step, Integer#times... -
Integer
# downto(min) {|n| . . . } -> self (3) -
self から min まで 1 ずつ減らしながらブロックを繰り返し実行します。 self < min であれば何もしません。
...し実行します。
self < min であれば何もしません。
@param min 数値
@return self を返します。
@see Integer#upto, Numeric#step, Integer#times... -
Integer
# even? -> bool (3) -
自身が偶数であれば真を返します。 そうでない場合は偽を返します。
自身が偶数であれば真を返します。
そうでない場合は偽を返します。 -
Integer
# gcd(n) -> Integer (3) -
自身と整数 n の最大公約数を返します。
...# => 1
3.gcd(-7) # => 1
((1<<31)-1).gcd((1<<61)-1) # => 1
また、self や n が 0 だった場合は、0 ではない方の整数の絶対値を返します。
3.gcd(0) # => 3
0.gcd(-7) # => 7
@see Integer#lcm, Integer#gcdlcm... -
Integer
# gcdlcm(n) -> [Integer] (3) -
自身と整数 n の最大公約数と最小公倍数の配列 [self.gcd(n), self.lcm(n)] を返します。
...します。
@raise ArgumentError n に整数以外のものを指定すると発生します。
例:
2.gcdlcm(2) # => [2, 2]
3.gcdlcm(-7) # => [1, 21]
((1<<31)-1).gcdlcm((1<<61)-1) # => [1, 4951760154835678088235319297]
@see Integer#gcd, Integer#lcm... -
Integer
# integer? -> true (3) -
常に真を返します。
常に真を返します。 -
Integer
# lcm(n) -> Integer (3) -
自身と整数 n の最小公倍数を返します。
...# => 2
3.lcm(-7) # => 21
((1<<31)-1).lcm((1<<61)-1) # => 4951760154835678088235319297
また、self や n が 0 だった場合は、0 を返します。
3.lcm(0) # => 0
0.lcm(-7) # => 0
@see Integer#gcd, Integer#gcdlcm... -
Integer
# next -> Fixnum | Bignum (3) -
self の次の整数を返します。
self の次の整数を返します。 -
Integer
# numerator -> Integer (3) -
分子(常に自身)を返します。
...分子(常に自身)を返します。
@return 分子を返します。
@see Integer#denominator... -
Integer
# odd? -> bool (3) -
自身が奇数であれば真を返します。 そうでない場合は偽を返します。
自身が奇数であれば真を返します。
そうでない場合は偽を返します。 -
Integer
# ord -> Integer (3) -
自身を返します。
自身を返します。
10.ord #=> 10
?a.ord #=> 97自身を返します。
10.ord #=> 10
# String#ord
?a.ord #=> 97
@see String#ord -
Integer
# pred -> Integer (3) -
self から -1 した値を返します。
self から -1 した値を返します。
1.pred #=> 0
(-1).pred #=> -2 -
Integer
# rationalize -> Rational (3) -
自身を Rational に変換します。
自身を Rational に変換します。
@param eps 許容する誤差
引数 eps は常に無視されます。
例:
2.rationalize # => (2/1)
2.rationalize(100) # => (2/1)
2.rationalize(0.1) # => (2/1) -
Integer
# rationalize(eps) -> Rational (3) -
自身を Rational に変換します。
自身を Rational に変換します。
@param eps 許容する誤差
引数 eps は常に無視されます。
例:
2.rationalize # => (2/1)
2.rationalize(100) # => (2/1)
2.rationalize(0.1) # => (2/1) -
Integer
# succ -> Fixnum | Bignum (3) -
self の次の整数を返します。
self の次の整数を返します。 -
Integer
# times -> Enumerable :: Enumerator (3) -
self 回だけ繰り返します。 self が正の整数でない場合は何もしません。
...数値が渡されます。
3.times { puts "Hello, World!" } # Hello, World! と3行続いて表示される。
0.times { puts "Hello, World!" } # 何も表示されない。
5.times {|n| print n } # 01234 と表示される。
@see Integer#upto, Integer#downto, Numeric#step... -
Integer
# times -> Enumerator (3) -
self 回だけ繰り返します。 self が正の整数でない場合は何もしません。
...数値が渡されます。
3.times { puts "Hello, World!" } # Hello, World! と3行続いて表示される。
0.times { puts "Hello, World!" } # 何も表示されない。
5.times {|n| print n } # 01234 と表示される。
@see Integer#upto, Integer#downto, Numeric#step... -
Integer
# times {|n| . . . } -> self (3) -
self 回だけ繰り返します。 self が正の整数でない場合は何もしません。
...数値が渡されます。
3.times { puts "Hello, World!" } # Hello, World! と3行続いて表示される。
0.times { puts "Hello, World!" } # 何も表示されない。
5.times {|n| print n } # 01234 と表示される。
@see Integer#upto, Integer#downto, Numeric#step... -
Integer
# to _ i -> self (3) -
self を返します。
self を返します。 -
Integer
# to _ int -> self (3) -
self を返します。
self を返します。 -
Integer
# to _ r -> Rational (3) -
自身を Rational に変換します。
自身を Rational に変換します。
例:
1.to_r # => (1/1)
(1<<64).to_r # => (18446744073709551616/1) -
Integer
# to _ s -> String (3) -
整数を 10 進文字列表現に変換します。
整数を 10 進文字列表現に変換します。
引数を指定すれば、それを基数とした文字列表
現に変換します。
p 10.to_s(2) # => "1010"
p 10.to_s(8) # => "12"
p 10.to_s(16) # => "a"
p 35.to_s(36) # => "z"
@return 数値の文字列表現
@param base 基数となる 2 - 36 の数値。
@raise ArgumentError base に 2 - 36 以外の数値を指定した場合に発生します。 -
Integer
# to _ s(base) -> String (3) -
整数を 10 進文字列表現に変換します。
整数を 10 進文字列表現に変換します。
引数を指定すれば、それを基数とした文字列表
現に変換します。
p 10.to_s(2) # => "1010"
p 10.to_s(8) # => "12"
p 10.to_s(16) # => "a"
p 35.to_s(36) # => "z"
@return 数値の文字列表現
@param base 基数となる 2 - 36 の数値。
@raise ArgumentError base に 2 - 36 以外の数値を指定した場合に発生します。 -
Integer
# upto(max) -> Enumerable :: Enumerator (3) -
self から max まで 1 ずつ増やしながら繰り返します。 self > max であれば何もしません。
...繰り返します。
self > max であれば何もしません。
@param max 数値
@return self を返します。
@see Integer#downto, Numeric#step, Integer#times... -
Integer
# upto(max) -> Enumerator (3) -
self から max まで 1 ずつ増やしながら繰り返します。 self > max であれば何もしません。
...繰り返します。
self > max であれば何もしません。
@param max 数値
@return self を返します。
@see Integer#downto, Numeric#step, Integer#times... -
Integer
# upto(max) {|n| . . . } -> Fixnum | Bignum (3) -
self から max まで 1 ずつ増やしながら繰り返します。 self > max であれば何もしません。
...繰り返します。
self > max であれば何もしません。
@param max 数値
@return self を返します。
@see Integer#downto, Numeric#step, Integer#times... -
Integer
. induced _ from(num) -> Integer (3) -
num を Integer に変換した結果を返します。 引数が数値の場合は小数部が切り捨てられ、そうでない場合はTypeErrorをraiseします。
...num を Integer に変換した結果を返します。
引数が数値の場合は小数部が切り捨てられ、そうでない場合はTypeErrorをraiseします。
Integer.induced_from 1.4 #=> 1
Integer.induced_from 1.9 #=> 1
Integer.induced_from -1.9 #=> -1
Integer.induced_from '1...
