ライブラリ
- ビルトイン (335)
- benchmark (1)
- bigdecimal (21)
-
bigdecimal
/ util (1) -
cgi
/ core (2) - csv (17)
- date (19)
- dbm (2)
- digest (4)
-
digest
/ sha2 (2) - drb (3)
-
drb
/ timeridconv (1) - etc (8)
- fiddle (17)
-
fiddle
/ import (2) - gdbm (2)
- getoptlong (1)
-
io
/ console (1) -
io
/ wait (1) - ipaddr (5)
-
irb
/ context (3) -
irb
/ ext / history (2) -
irb
/ ext / save-history (2) -
irb
/ frame (2) - json (5)
- logger (4)
- matrix (24)
- mkmf (8)
-
net
/ ftp (3) -
net
/ http (15) -
net
/ imap (16) -
net
/ pop (8) -
net
/ smtp (3) - observer (1)
- openssl (48)
- optparse (13)
- ostruct (1)
- pathname (12)
- prettyprint (2)
- prime (11)
- psych (13)
-
rdoc
/ stats (4) - resolv (10)
- resolv-replace (3)
- rexml (3)
-
rexml
/ document (11) -
rinda
/ rinda (1) -
rinda
/ tuplespace (1) - ripper (2)
-
ripper
/ filter (2) -
ripper
/ lexer (2) - rubygems (1)
-
rubygems
/ config _ file (1) -
rubygems
/ dependency (1) -
rubygems
/ package / tar _ header (9) -
rubygems
/ package / tar _ reader (1) -
rubygems
/ package / tar _ reader / entry (2) -
rubygems
/ package / tar _ writer (4) -
rubygems
/ remote _ fetcher (1) -
rubygems
/ source _ index (3) -
rubygems
/ source _ info _ cache _ entry (1) -
rubygems
/ specification (1) -
rubygems
/ user _ interaction (2) - scanf (2)
- sdbm (2)
- set (3)
- shell (12)
-
shell
/ command-processor (9) -
shell
/ filter (9) -
shell
/ process-controller (2) -
shell
/ system-command (1) - socket (33)
- stringio (11)
- strscan (11)
- sync (1)
-
syslog
/ logger (1) - tempfile (2)
- tracer (1)
- uri (1)
-
webrick
/ httprequest (1) -
webrick
/ httpresponse (4) -
webrick
/ httpservlet / filehandler (1) -
webrick
/ httpversion (4) -
webrick
/ log (2) -
win32
/ registry (2) - win32ole (18)
- zlib (17)
クラス
-
ARGF
. class (8) - Addrinfo (6)
- Array (28)
- BasicObject (1)
- BasicSocket (6)
-
Benchmark
:: Job (1) - BigDecimal (21)
- Binding (1)
- CSV (10)
-
CSV
:: FieldInfo (2) -
CSV
:: Row (3) -
CSV
:: Table (2) - Complex (2)
- DBM (2)
-
DRb
:: DRbIdConv (1) -
DRb
:: DRbObject (1) -
DRb
:: DRbServer (1) -
DRb
:: TimerIdConv (1) - Date (14)
- DateTime (5)
-
Digest
:: Base (4) -
Digest
:: SHA2 (2) - Dir (3)
-
Encoding
:: Converter (4) - Enumerator (1)
-
Enumerator
:: ArithmeticSequence (2) -
Enumerator
:: Chain (1) -
Etc
:: Group (1) -
Etc
:: Passwd (6) -
Fiddle
:: CStruct (1) -
Fiddle
:: Closure (3) -
Fiddle
:: Function (4) -
Fiddle
:: Handle (4) -
Fiddle
:: Pointer (6) - File (1)
-
File
:: Stat (17) - Float (9)
- GDBM (2)
-
Gem
:: ConfigFile (1) -
Gem
:: Dependency (1) -
Gem
:: Package :: TarHeader (9) -
Gem
:: Package :: TarReader (1) -
Gem
:: Package :: TarReader :: Entry (2) -
Gem
:: Package :: TarWriter :: BoundedStream (3) -
Gem
:: Package :: TarWriter :: RestrictedStream (1) -
Gem
:: RemoteFetcher (1) -
Gem
:: SourceIndex (3) -
Gem
:: SourceInfoCacheEntry (1) -
Gem
:: Specification (1) -
Gem
:: StreamUI :: SimpleProgressReporter (1) -
Gem
:: StreamUI :: VerboseProgressReporter (1) - GetoptLong (1)
- Hash (3)
- IO (19)
- IPAddr (5)
-
IRB
:: Context (7) -
IRB
:: Frame (2) - Integer (73)
-
JSON
:: State (4) - Logger (3)
-
Logger
:: LogDevice (1) - MatchData (7)
- Matrix (20)
-
Matrix
:: LUPDecomposition (1) - Method (3)
- Module (1)
-
Net
:: FTP (1) -
Net
:: FTP :: MLSxEntry (2) -
Net
:: HTTP (11) -
Net
:: IMAP (6) -
Net
:: IMAP :: BodyTypeBasic (1) -
Net
:: IMAP :: BodyTypeMessage (2) -
Net
:: IMAP :: BodyTypeText (2) -
Net
:: IMAP :: FetchData (1) -
Net
:: IMAP :: MailboxQuota (2) -
Net
:: IMAP :: StatusData (1) -
Net
:: IMAP :: ThreadMember (1) -
Net
:: POP3 (5) -
Net
:: POPMail (3) -
Net
:: SMTP (3) - NilClass (1)
- Numeric (21)
- Object (7)
-
OpenSSL
:: ASN1 :: ASN1Data (1) -
OpenSSL
:: BN (5) -
OpenSSL
:: Cipher (3) -
OpenSSL
:: Digest (2) -
OpenSSL
:: OCSP :: BasicResponse (2) -
OpenSSL
:: OCSP :: Request (1) -
OpenSSL
:: OCSP :: Response (1) -
OpenSSL
:: PKCS7 :: RecipientInfo (1) -
OpenSSL
:: PKCS7 :: SignerInfo (1) -
OpenSSL
:: PKey :: DH (1) -
OpenSSL
:: PKey :: EC :: Group (2) -
OpenSSL
:: SSL :: SSLContext (9) -
OpenSSL
:: SSL :: SSLSocket (4) -
OpenSSL
:: SSL :: Session (1) -
OpenSSL
:: X509 :: CRL (1) -
OpenSSL
:: X509 :: Certificate (2) -
OpenSSL
:: X509 :: Name (2) -
OpenSSL
:: X509 :: Request (1) -
OpenSSL
:: X509 :: Store (1) -
OpenSSL
:: X509 :: StoreContext (2) - OpenStruct (1)
- OptionParser (13)
- Pathname (12)
- PrettyPrint (2)
- Prime (2)
-
Prime
:: EratosthenesGenerator (2) -
Prime
:: Generator23 (2) -
Prime
:: PseudoPrimeGenerator (1) -
Prime
:: TrialDivisionGenerator (2) - Proc (3)
-
Process
:: Status (7) -
Psych
:: Emitter (2) -
Psych
:: Nodes :: Document (1) -
Psych
:: Nodes :: Mapping (1) -
Psych
:: Nodes :: Scalar (1) -
Psych
:: Nodes :: Sequence (1) -
Psych
:: Nodes :: Stream (1) -
Psych
:: Parser :: Mark (3) -
Psych
:: SyntaxError (3) -
RDoc
:: Options (2) -
RDoc
:: Stats (4) -
REXML
:: Attributes (2) -
REXML
:: Elements (2) -
REXML
:: Formatters :: Pretty (1) -
REXML
:: Parent (6) -
REXML
:: ParseException (3) - Random (6)
- Range (2)
- Rational (8)
- Regexp (5)
-
Resolv
:: DNS :: Resource :: IN :: SRV (3) -
Resolv
:: DNS :: Resource :: IN :: WKS (1) -
Resolv
:: DNS :: Resource :: MX (1) -
Resolv
:: DNS :: Resource :: SOA (5) -
Rinda
:: SimpleRenewer (1) -
Rinda
:: TupleEntry (1) - Ripper (2)
-
Ripper
:: Filter (2) -
Ripper
:: Lexer (2) -
RubyVM
:: AbstractSyntaxTree :: Node (4) -
RubyVM
:: InstructionSequence (1) - SDBM (2)
- Set (3)
- Shell (12)
-
Shell
:: CommandProcessor (9) -
Shell
:: Filter (9) -
Shell
:: ProcessController (2) -
Shell
:: SystemCommand (1) - SignalException (1)
-
Socket
:: AncillaryData (7) -
Socket
:: Ifaddr (3) -
Socket
:: Option (5) - String (28)
- StringIO (11)
- StringScanner (11)
- Struct (6)
- Symbol (3)
-
Syslog
:: Logger (1) - SystemCallError (1)
- SystemExit (1)
- TCPServer (1)
- Tempfile (2)
- Thread (5)
-
Thread
:: Backtrace :: Location (1) -
Thread
:: Mutex (1) -
Thread
:: Queue (3) -
Thread
:: SizedQueue (3) - Time (21)
- TracePoint (1)
- Tracer (1)
- UDPSocket (6)
- UNIXServer (1)
- UNIXSocket (1)
-
URI
:: Generic (1) - UnboundMethod (4)
- Vector (3)
-
WEBrick
:: BasicLog (2) -
WEBrick
:: Cookie (4) -
WEBrick
:: HTTPRequest (1) -
WEBrick
:: HTTPResponse (4) -
WEBrick
:: HTTPServlet :: DefaultFileHandler (1) -
WEBrick
:: HTTPVersion (4) -
WIN32OLE
_ METHOD (7) -
WIN32OLE
_ TYPE (4) -
WIN32OLE
_ TYPELIB (2) -
WIN32OLE
_ VARIABLE (2) -
WIN32OLE
_ VARIANT (3) -
Win32
:: Registry (2) -
Zlib
:: GzipFile (3) -
Zlib
:: GzipReader (5) -
Zlib
:: GzipWriter (3) -
Zlib
:: ZStream (6)
モジュール
-
CGI
:: QueryExtension (2) - Enumerable (16)
-
Fiddle
:: Importer (1) -
Gem
:: QuickLoader (1) -
JSON
:: Generator :: GeneratorMethods :: Integer (1) - Kernel (8)
-
Net
:: HTTPHeader (4) - Observable (1)
-
OpenSSL
:: Buffering (3) -
OpenSSL
:: SSL :: SocketForwarder (1) -
Sync
_ m (1)
キーワード
- % (2)
- & (2)
- * (1)
- ** (2)
- + (1)
- - (1)
- -@ (2)
-
/ (1) - < (1)
- << (4)
- <= (1)
- <=> (6)
- == (1)
- === (1)
- =~ (3)
- > (1)
- >= (1)
- >> (2)
- [] (10)
- []= (6)
- ^ (1)
-
_ _ drbref (1) -
_ _ id _ _ (1) - abi (1)
- abs (1)
-
add
_ trace _ func (1) - adler (1)
- afamily (1)
- age (1)
- allbits? (1)
- any? (6)
- anybits? (1)
- args (1)
- arity (3)
-
asn1
_ flag (1) - attr (1)
-
avail
_ in (1) -
avail
_ out (1) -
back
_ trace _ limit (1) -
back
_ trace _ limit= (1) - begin (1)
- bind (1)
- binwrite (1)
-
bit
_ length (1) - blksize (1)
-
block
_ length (3) -
block
_ size (1) - blocks (1)
- bottom (1)
-
bsearch
_ index (2) -
buffer
_ initial _ length (1) -
bulk
_ threshold (1) - bytes (2)
-
bytes
_ read (1) - bytesize (1)
-
calculate
_ integers _ for _ gem _ version (1) - call (1)
- ceil (6)
- change (1)
- charpos (1)
-
check
_ nonce (1) -
check
_ signedness (2) -
check
_ sizeof (2) - checksum (1)
- chmod (4)
- chown (4)
- chr (3)
- cipher (1)
- ciphers (1)
- class (1)
- classify (1)
- close (1)
- codepoints (2)
- coerce (2)
- cofactor (1)
-
cofactor
_ expansion (1) - column (4)
-
column
_ count (1) -
column
_ size (1) -
compute
_ key (1) - concat (2)
- connect (1)
-
content
_ length (4) -
content
_ length= (1) - context (1)
-
continue
_ timeout (1) - converters (1)
-
convertible
_ int (2) -
copy
_ nonce (1) - count (9)
-
count
_ observers (1) -
coverage
_ report (1) - crc (1)
- ctype (1)
- cwday (1)
- cweek (1)
- cwyear (1)
-
data
_ type (1) - day (2)
- debug (1)
- debug? (1)
-
debug
_ level (1) -
default
_ port (1) - degree (1)
- delete (4)
- denominator (5)
- depth (1)
- depth= (1)
-
dev
_ major (1) -
dev
_ minor (1) - devmajor (1)
- devminor (1)
- dig (1)
-
digest
_ length (3) - digits (2)
- dispid (1)
- div (2)
- divmod (1)
- downto (2)
-
elements
_ to _ i (2) - encoding (1)
- end (1)
- errno (1)
- error (2)
-
error
_ depth (1) -
eval
_ history (1) -
eval
_ history= (1) - even? (1)
- exist? (1)
- exitstatus (1)
- expire (2)
- exponent (1)
- expunge (1)
- facts (1)
- family (3)
- fcntl (3)
- fdiv (1)
-
fetch
_ size (1) -
field
_ size _ limit (1) - fileno (4)
-
find
_ index (9) -
first
_ column (1) -
first
_ lineno (2) - flags (1)
- floor (6)
- gcd (1)
- gcdlcm (1)
-
get
_ thread _ no (1) - getbyte (4)
- getc (1)
- getpeereid (1)
- gid (4)
-
gmt
_ offset (1) - gmtoff (1)
- hash (21)
-
hash
_ old (1) - helpcontext (2)
- hex (1)
- hour (2)
- ifindex (1)
- indent (1)
- indentation (1)
- index (12)
- ino (1)
- inspect (1)
- int (2)
-
int
_ from _ prime _ division (1) - integer? (2)
- invkind (1)
- ioctl (2)
-
ip
_ pktinfo (1) -
ip
_ port (1) -
ip
_ unpack (1) -
ipv6
_ pktinfo (1) -
ipv6
_ pktinfo _ ifindex (1) -
iv
_ len (1) - jd (1)
-
keep
_ alive _ timeout (1) -
key
_ len (1) - kill (2)
-
kill
_ job (1) -
laplace
_ expansion (1) -
last
_ column (1) -
last
_ lineno (1) - lchmod (1)
- lchown (1)
- lcm (1)
- ld (1)
- left (1)
- length (22)
- level (6)
- level= (1)
- lex (1)
- limit (1)
- line (4)
-
line
_ width (1) - lineno (9)
- lines (2)
- linger (1)
-
local
_ port (1) - magnitude (1)
- major (1)
- major= (1)
-
major
_ version (2) - match? (1)
-
matched
_ size (1) - matchedsize (1)
- max (1)
-
max
_ age (1) -
max
_ age= (1) -
max
_ nesting (1) - maxwidth (1)
- mday (2)
- method (1)
- min (2)
- minimum (1)
- minor (1)
- minor= (1)
-
minor
_ version (2) - minute (1)
- mjd (1)
- mode (2)
- modulo (1)
- mon (2)
- month (2)
- mtime (1)
-
n
_ bytes (1) -
n
_ mails (1) -
named
_ captures (1) - next (4)
- nlink (1)
- nobits? (1)
- nread (1)
- nsec (1)
-
num
_ bits (1) -
num
_ bytes (1) -
num
_ classes (1) -
num
_ files (1) -
num
_ methods (1) -
num
_ modules (1) -
num
_ waiting (1) - number (1)
- numerator (4)
-
object
_ id (1) - oct (1)
- odd? (1)
- offset (3)
-
offset
_ vtbl (1) -
ole
_ type _ detail (1) - on (12)
- one? (6)
-
open
_ timeout (3) - optname (1)
- ord (2)
- ordering (1)
-
os
_ code (1) - owner (1)
- pack (2)
- parse (1)
- pathconf (1)
- pending (1)
- pfamily (1)
- pid (3)
- pivots (1)
- pointer (1)
- port (4)
- pos (9)
- position (1)
- pow (2)
- power (2)
- precs (1)
- pred (1)
- preference (1)
- prefix (1)
-
prepare
_ range (1) - prime? (1)
-
prime
_ division (2) -
primitive
_ convert (4) - priority (2)
- priority= (1)
- protocol (2)
-
proxy
_ port (1) - proxyport (1)
- ptr (1)
-
public
_ method (1) - pwrite (1)
- quota (2)
- rand (3)
-
range
_ length (1) - rank (1)
-
rank
_ e (1) - rationalize (2)
- rdev (1)
-
rdev
_ major (1) -
rdev
_ minor (1) - read (1)
-
read
_ timeout (3) - readbyte (3)
- readchar (1)
- real? (1)
-
recv
_ io (1) - recvmsg (1)
-
recvmsg
_ nonblock (1) - refresh (1)
- remainder (1)
- renew (1)
-
rest
_ size (1) - restsize (1)
- retry (1)
-
return
_ vtype (1) - rewind (1)
- rindex (4)
- rm (3)
- round (8)
-
row
_ count (1) -
row
_ size (1) -
safe
_ level (2) -
save
_ history (1) -
save
_ history= (1) - scanf (2)
- search (1)
- sec (2)
- second (1)
- seed (1)
- send (5)
- sendmsg (1)
-
sendmsg
_ nonblock (1) -
sent
_ size (1) - seqno (2)
- serial (4)
-
server
_ port (1) -
session
_ cache _ mode (1) -
session
_ cache _ size (1) -
session
_ cache _ stats (1) -
set
_ trace _ func (1) - setbyte (1)
-
sev
_ threshold (1) - sfork (1)
- sign (1)
- signo (1)
-
singleton
_ class (1) - size (45)
- size? (4)
-
size
_ opt _ params (1) -
size
_ params (1) - sizeof (1)
- skip (1)
-
skip
_ until (1) - sleep (1)
- socktype (1)
- sort (1)
-
sort
_ by (2) -
source
_ location (4) -
specification
_ version (1) - split (1)
-
ssl
_ timeout (2) - start (1)
- state (1)
- status (5)
- step (9)
- stopsig (1)
- style (3)
- subsec (1)
- succ (4)
- sum (5)
-
summary
_ width (1) - sym (1)
-
sync
_ ex _ count (1) - sysaccept (2)
- sysopen (1)
- sysseek (1)
- syswrite (3)
-
tab
_ width (1) - tag (1)
- tell (7)
- termsig (1)
- test (3)
- timeout (2)
- times (2)
-
to
_ a (1) -
to
_ bn (1) -
to
_ d (1) -
to
_ f (2) -
to
_ i (19) -
to
_ id (2) -
to
_ int (6) -
to
_ json (1) -
to
_ r (1) -
to
_ s (3) - top (1)
-
total
_ in (1) -
total
_ out (1) - tr (1)
- trace (1)
- truncate (7)
-
try
_ constant (2) -
tv
_ nsec (1) -
tv
_ sec (1) -
tv
_ usec (1) - type (1)
- typekind (1)
- uid (3)
-
uid
_ search (1) -
uid
_ sort (1) - ungetc (1)
- unlink (1)
- unpack (1)
-
upper
_ bound (1) - upto (2)
- usage (1)
- usec (1)
-
utc
_ offset (1) - utime (4)
-
values
_ at (1) - varkind (1)
- vartype (1)
-
verify
_ depth (2) -
verify
_ mode (2) -
verify
_ result (1) - version (6)
- version= (1)
- vhid (1)
- wday (2)
- weight (1)
- width (2)
- winsize (1)
-
world
_ readable? (1) -
world
_ writable? (1) - write (9)
-
write
_ nonblock (3) - written (1)
- yday (2)
- year (2)
- | (1)
- ~ (2)
検索結果
先頭5件
-
Integer
# integer? -> true (81343.0) -
常に真を返します。
常に真を返します。
//emlist[][ruby]{
1.integer? # => true
1.0.integer? # => false
//} -
Integer
# prime _ division(generator = Prime :: Generator23 . new) -> [[Integer , Integer]] (63610.0) -
自身を素因数分解した結果を返します。
自身を素因数分解した結果を返します。
@param generator 素数生成器のインスタンスを指定します。
@return 素因数とその指数から成るペアを要素とする配列です。つまり、戻り値の各要素は2要素の配列 [n,e] であり、それぞれの内部配列の第1要素 n は self の素因数、第2要素は n**e が self を割り切る最大の自然数 e です。
@raise ZeroDivisionError self がゼロである場合に発生します。
@see Prime#prime_division
//emlist[例][ruby]{
require 'prime'
12.p... -
Integer
# div(other) -> Integer (63415.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 => ... -
Integer
# gcd(n) -> Integer (63343.0) -
自身と整数 n の最大公約数を返します。
自身と整数 n の最大公約数を返します。
@raise ArgumentError n に整数以外のものを指定すると発生します。
//emlist[][ruby]{
2.gcd(2) # => 2
3.gcd(7) # => 1
3.gcd(-7) # => 1
((1<<31)-1).gcd((1<<61)-1) # => 1
//}
また、self や n が 0 だった場合は、0 ではない方の整数の絶対値を返します。
//emlist[][ruby]{
3.gcd(... -
Integer
# gcdlcm(n) -> [Integer] (63343.0) -
自身と整数 n の最大公約数と最小公倍数の配列 [self.gcd(n), self.lcm(n)] を返します。
自身と整数 n の最大公約数と最小公倍数の配列 [self.gcd(n), self.lcm(n)]
を返します。
@raise ArgumentError n に整数以外のものを指定すると発生します。
//emlist[][ruby]{
2.gcdlcm(2) # => [2, 2]
3.gcdlcm(-7) # => [1, 21]
((1<<31)-1).gcdlcm((1<<61)-1) # => [1, 4951760154835678088235319297]
//}
@see Integer#gc... -
Integer
# lcm(n) -> Integer (63343.0) -
自身と整数 n の最小公倍数を返します。
自身と整数 n の最小公倍数を返します。
@raise ArgumentError n に整数以外のものを指定すると発生します。
//emlist[][ruby]{
2.lcm(2) # => 2
3.lcm(-7) # => 21
((1<<31)-1).lcm((1<<61)-1) # => 4951760154835678088235319297
//}
また、self や n が 0 だった場合は、0 を返します。
//emlist[][ruby]{
3.lcm(0) ... -
Integer
# upto(max) {|n| . . . } -> Integer (63343.0) -
self から max まで 1 ずつ増やしながら繰り返します。 self > max であれば何もしません。
self から max まで 1 ずつ増やしながら繰り返します。
self > max であれば何もしません。
@param max 数値
@return self を返します。
//emlist[][ruby]{
5.upto(10) {|i| print i, " " } # => 5 6 7 8 9 10
//}
@see Integer#downto, Numeric#step, Integer#times -
Integer
# next -> Integer (63328.0) -
self の次の整数を返します。
self の次の整数を返します。
//emlist[][ruby]{
1.next #=> 2
(-1).next #=> 0
1.succ #=> 2
(-1).succ #=> 0
//}
@see Integer#pred -
Integer
# succ -> Integer (63328.0) -
self の次の整数を返します。
self の次の整数を返します。
//emlist[][ruby]{
1.next #=> 2
(-1).next #=> 0
1.succ #=> 2
(-1).succ #=> 0
//}
@see Integer#pred -
Integer
# bit _ length -> Integer (63325.0) -
self を表すのに必要なビット数を返します。
self を表すのに必要なビット数を返します。
「必要なビット数」とは符号ビットを除く最上位ビットの位置の事を意味しま
す。2**n の場合は n+1 になります。self にそのようなビットがない(0 や
-1 である)場合は 0 を返します。
//emlist[例: ceil(log2(int < 0 ? -int : int+1)) と同じ結果][ruby]{
(-2**12-1).bit_length # => 13
(-2**12).bit_length # => 12
(-2**12+1).bit_length # => 12
-0x101.bit... -
Integer
# denominator -> Integer (63325.0) -
分母(常に1)を返します。
分母(常に1)を返します。
@return 分母を返します。
//emlist[][ruby]{
10.denominator # => 1
-10.denominator # => 1
//}
@see Integer#numerator -
Integer
# numerator -> Integer (63325.0) -
分子(常に自身)を返します。
分子(常に自身)を返します。
@return 分子を返します。
//emlist[][ruby]{
10.numerator # => 10
-10.numerator # => -10
//}
@see Integer#denominator -
Integer
# pow(other , modulo) -> Integer (63325.0) -
算術演算子。冪(べき乗)を計算します。
算術演算子。冪(べき乗)を計算します。
@param other 二項演算の右側の引数(対象)
@param modulo 指定すると、計算途中に巨大な値を生成せずに (self**other) % modulo と同じ結果を返します。
@return 計算結果
@raise TypeError 2引数 pow で Integer 以外を指定した場合に発生します。
@raise RangeError 2引数 pow で other に負の数を指定した場合に発生します。
//emlist[][ruby]{
2 ** 3 # => 8
2 ** 0 # => 1
0 ** 0 # => 1
... -
Integer
# pred -> Integer (63325.0) -
self から -1 した値を返します。
self から -1 した値を返します。
//emlist[][ruby]{
1.pred #=> 0
(-1).pred #=> -2
//}
@see Integer#next -
Integer
# size -> Integer (63325.0) -
整数の実装上のサイズをバイト数で返します。
整数の実装上のサイズをバイト数で返します。
//emlist[][ruby]{
p 1.size # => 8
p 0x1_0000_0000.size # => 8
//}
@see Integer#bit_length -
Integer
# abs -> Integer (63310.0) -
self の絶対値を返します。
self の絶対値を返します。
//emlist[][ruby]{
-12345.abs # => 12345
12345.abs # => 12345
-1234567890987654321.abs # => 1234567890987654321
//} -
Integer
# digits -> [Integer] (63310.0) -
base を基数として self を位取り記数法で表記した数値を配列で返します。 base を指定しない場合の基数は 10 です。
base を基数として self を位取り記数法で表記した数値を配列で返します。
base を指定しない場合の基数は 10 です。
//emlist[][ruby]{
16.digits # => [6, 1]
16.digits(16) # => [0, 1]
//}
self は非負整数でなければいけません。非負整数でない場合は、Math::DomainErrorが発生します。
//emlist[][ruby]{
-10.digits # Math::DomainError: out of domain が発生
//}
@return 位取り記数法で表した時の数... -
Integer
# digits(base) -> [Integer] (63310.0) -
base を基数として self を位取り記数法で表記した数値を配列で返します。 base を指定しない場合の基数は 10 です。
base を基数として self を位取り記数法で表記した数値を配列で返します。
base を指定しない場合の基数は 10 です。
//emlist[][ruby]{
16.digits # => [6, 1]
16.digits(16) # => [0, 1]
//}
self は非負整数でなければいけません。非負整数でない場合は、Math::DomainErrorが発生します。
//emlist[][ruby]{
-10.digits # Math::DomainError: out of domain が発生
//}
@return 位取り記数法で表した時の数... -
Integer
# magnitude -> Integer (63310.0) -
self の絶対値を返します。
self の絶対値を返します。
//emlist[][ruby]{
-12345.abs # => 12345
12345.abs # => 12345
-1234567890987654321.abs # => 1234567890987654321
//} -
Integer
# &(other) -> Integer (63307.0) -
ビット二項演算子。論理積を計算します。
ビット二項演算子。論理積を計算します。
@param other 数値
//emlist[][ruby]{
1 & 1 # => 1
2 & 3 # => 2
//} -
Integer
# -@ -> Integer (63307.0) -
単項演算子の - です。 self の符号を反転させたものを返します。
単項演算子の - です。
self の符号を反転させたものを返します。
//emlist[][ruby]{
- 10 # => -10
- -10 # => 10
//} -
Integer
# <<(bits) -> Integer (63307.0) -
シフト演算子。bits だけビットを左にシフトします。
シフト演算子。bits だけビットを左にシフトします。
@param bits シフトさせるビット数
//emlist[][ruby]{
printf("%#b\n", 0b0101 << 1) # => 0b1010
p -1 << 1 # => -2
//} -
Integer
# >>(bits) -> Integer (63307.0) -
シフト演算子。bits だけビットを右にシフトします。
シフト演算子。bits だけビットを右にシフトします。
右シフトは、符号ビット(最上位ビット(MSB))が保持されます。
bitsが実数の場合、小数点以下を切り捨てた値でシフトします。
@param bits シフトさせるビット数
//emlist[][ruby]{
printf("%#b\n", 0b0101 >> 1) # => 0b10
p -1 >> 1 # => -1
//} -
Integer
# [](nth) -> Integer (63307.0) -
nth 番目のビット(最下位ビット(LSB)が 0 番目)が立っている時 1 を、そうでなければ 0 を返します。
nth 番目のビット(最下位ビット(LSB)が 0 番目)が立っている時 1
を、そうでなければ 0 を返します。
@param nth 何ビット目を指すかの数値
@return 1 か 0
//emlist[][ruby]{
a = 0b11001100101010
30.downto(0) {|n| print a[n] }
# => 0000000000000000011001100101010
a = 9**15
50.downto(0) {|n| print a[n] }
# => 00010111011010000011100001111001010011110... -
Integer
# ^(other) -> Integer (63307.0) -
ビット二項演算子。排他的論理和を計算します。
ビット二項演算子。排他的論理和を計算します。
@param other 数値
//emlist[][ruby]{
1 ^ 1 # => 0
2 ^ 3 # => 1
//} -
Integer
# ceil(ndigits = 0) -> Integer (63307.0) -
self と等しいかより大きな整数のうち最小のものを返します。
self と等しいかより大きな整数のうち最小のものを返します。
@param ndigits 10進数での小数点以下の有効桁数を整数で指定します。
負の整数を指定した場合、小数点位置から左に少なくとも n 個の 0 が並びます。
//emlist[][ruby]{
1.ceil # => 1
1.ceil(2) # => 1
18.ceil(-1) # => 20
(-18).ceil(-1) # => -10
//}
@see Numeric#ceil -
Integer
# divmod(other) -> [Integer , Numeric] (63307.0) -
self を other で割った商 q と余り r を、 [q, r] という 2 要素の配列にし て返します。 商 q は常に整数ですが、余り r は整数であるとは限りません。
self を other で割った商 q と余り r を、 [q, r] という 2 要素の配列にし
て返します。 商 q は常に整数ですが、余り r は整数であるとは限りません。
@param other self を割る数。
@see Numeric#divmod -
Integer
# floor(ndigits = 0) -> Integer (63307.0) -
self と等しいかより小さな整数のうち最大のものを返します。
self と等しいかより小さな整数のうち最大のものを返します。
@param ndigits 10進数での小数点以下の有効桁数を整数で指定します。
負の整数を指定した場合、小数点位置から左に少なくとも n 個の 0 が並びます。
//emlist[][ruby]{
1.floor # => 1
1.floor(2) # => 1
18.floor(-1) # => 10
(-18).floor(-1) # => -20
//}
@see Numeric#floor -
Integer
# ord -> Integer (63307.0) -
自身を返します。
自身を返します。
//emlist[][ruby]{
10.ord #=> 10
# String#ord
?a.ord #=> 97
//}
@see String#ord -
Integer
# round(ndigits = 0 , half: :up) -> Integer (63307.0) -
self ともっとも近い整数を返します。
self ともっとも近い整数を返します。
@param ndigits 10進数での小数点以下の有効桁数を整数で指定します。
負の整数を指定した場合、小数点位置から左に少なくとも n 個の 0 が並びます。
@param half ちょうど半分の値の丸め方を指定します。
サポートされている値は以下の通りです。
* :up or nil: 0から遠い方に丸められます。
* :even: もっとも近い偶数に丸められます。
* :down: 0に近い方に丸められます。
//emlist[][ruby]{
1.round # =... -
Integer
# truncate(ndigits = 0) -> Integer (63307.0) -
0 から self までの整数で、自身にもっとも近い整数を返します。
0 から self までの整数で、自身にもっとも近い整数を返します。
@param ndigits 10進数での小数点以下の有効桁数を整数で指定します。
負の整数を指定した場合、小数点位置から左に少なくとも n 個の 0 が並びます。
//emlist[][ruby]{
1.truncate # => 1
1.truncate(2) # => 1
18.truncate(-1) # => 10
(-18).truncate(-1) # => -10
//}
@see Numeric#truncate -
Integer
# |(other) -> Integer (63307.0) -
ビット二項演算子。論理和を計算します。
ビット二項演算子。論理和を計算します。
@param other 数値
//emlist[][ruby]{
1 | 1 # => 1
2 | 3 # => 3
//} -
Integer
# ~ -> Integer (63307.0) -
ビット演算子。否定を計算します。
ビット演算子。否定を計算します。
//emlist[][ruby]{
~1 # => -2
~3 # => -4
~-4 # => 3
//} -
Integer
# / (other) -> Numeric (63076.0) -
除算の算術演算子。
除算の算術演算子。
other が Integer の場合、整商(整数の商)を Integer で返します。
普通の商(剰余を考えない商)を越えない最大の整数をもって整商とします。
other が Float、Rational、Complex の場合、普通の商を other と
同じクラスのインスタンスで返します。
@param other 二項演算の右側の引数(対象)
@return 計算結果
//emlist[例][ruby]{
7 / 2 # => 3
7 / -2 # => -4
7 / 2.0 # => 3.5
7 / Rational(2, 1) # => (7/2)
7... -
Integer
# to _ bn -> OpenSSL :: BN (63070.0) -
Integer を同じ数を表す OpenSSL::BN のオブジェクトに 変換します。
Integer を同じ数を表す OpenSSL::BN のオブジェクトに
変換します。
//emlist[][ruby]{
require 'openssl'
pp 5.to_bn #=> #<OpenSSL::BN 5>
pp (-5).to_bn #=> #<OpenSSL::BN -5>
//}
なお、実装は、以下のようになっています。
//emlist[][ruby]{
class Integer
def to_bn
OpenSSL::BN::new(self)
end
end
//}
@see OpenSSL::BN.new, OpenSSL::... -
Integer
# upto(max) -> Enumerator (63043.0) -
self から max まで 1 ずつ増やしながら繰り返します。 self > max であれば何もしません。
self から max まで 1 ずつ増やしながら繰り返します。
self > max であれば何もしません。
@param max 数値
@return self を返します。
//emlist[][ruby]{
5.upto(10) {|i| print i, " " } # => 5 6 7 8 9 10
//}
@see Integer#downto, Numeric#step, Integer#times -
Integer
# allbits?(mask) -> bool (63040.0) -
self & mask の全てのビットが 1 なら true を返します。
self & mask の全てのビットが 1 なら true を返します。
self & mask == mask と等価です。
@param mask ビットマスクを整数で指定します。
//emlist[][ruby]{
42.allbits?(42) # => true
0b1010_1010.allbits?(0b1000_0010) # => true
0b1010_1010.allbits?(0b1000_0001) # => false
0b1000_0010.allbits?(0b1010_1010) # => false
//}
@s... -
Integer
# anybits?(mask) -> bool (63040.0) -
self & mask のいずれかのビットが 1 なら true を返します。
self & mask のいずれかのビットが 1 なら true を返します。
self & mask != 0 と等価です。
@param mask ビットマスクを整数で指定します。
//emlist[][ruby]{
42.anybits?(42) # => true
0b1010_1010.anybits?(0b1000_0010) # => true
0b1010_1010.anybits?(0b1000_0001) # => true
0b1000_0010.anybits?(0b0010_1100) # => false
//}
@see... -
Integer
# downto(min) -> Enumerator (63040.0) -
self から min まで 1 ずつ減らしながらブロックを繰り返し実行します。 self < min であれば何もしません。
self から min まで 1 ずつ減らしながらブロックを繰り返し実行します。
self < min であれば何もしません。
@param min 数値
@return self を返します。
//emlist[][ruby]{
5.downto(1) {|i| print i, " " } # => 5 4 3 2 1
//}
@see Integer#upto, Numeric#step, Integer#times -
Integer
# downto(min) {|n| . . . } -> self (63040.0) -
self から min まで 1 ずつ減らしながらブロックを繰り返し実行します。 self < min であれば何もしません。
self から min まで 1 ずつ減らしながらブロックを繰り返し実行します。
self < min であれば何もしません。
@param min 数値
@return self を返します。
//emlist[][ruby]{
5.downto(1) {|i| print i, " " } # => 5 4 3 2 1
//}
@see Integer#upto, Numeric#step, Integer#times -
Integer
# nobits?(mask) -> bool (63040.0) -
self & mask のすべてのビットが 0 なら true を返します。
self & mask のすべてのビットが 0 なら true を返します。
self & mask == 0 と等価です。
@param mask ビットマスクを整数で指定します。
//emlist[][ruby]{
42.nobits?(42) # => false
0b1010_1010.nobits?(0b1000_0010) # => false
0b1010_1010.nobits?(0b1000_0001) # => false
0b0100_0101.nobits?(0b1010_1010) # => true
//}
@see In... -
Integer
# remainder(other) -> Numeric (63040.0) -
self を other で割った余り r を返します。
self を other で割った余り r を返します。
r の符号は self と同じになります。
@param other self を割る数。
//emlist[][ruby]{
5.remainder(3) # => 2
-5.remainder(3) # => -2
5.remainder(-3) # => 2
-5.remainder(-3) # => -2
-1234567890987654321.remainder(13731) # => -6966
-1234567890987654321.remainder(13731.24) #... -
Integer
# times -> Enumerator (63040.0) -
self 回だけ繰り返します。 self が正の整数でない場合は何もしません。
self 回だけ繰り返します。
self が正の整数でない場合は何もしません。
またブロックパラメータには 0 から self - 1 までの数値が渡されます。
//emlist[][ruby]{
3.times { puts "Hello, World!" } # Hello, World! と3行続いて表示される。
0.times { puts "Hello, World!" } # 何も表示されない。
5.times {|n| print n } # 01234 と表示される。
//}
@see Integer#upto, Integer#downto,... -
Integer
# times {|n| . . . } -> self (63040.0) -
self 回だけ繰り返します。 self が正の整数でない場合は何もしません。
self 回だけ繰り返します。
self が正の整数でない場合は何もしません。
またブロックパラメータには 0 から self - 1 までの数値が渡されます。
//emlist[][ruby]{
3.times { puts "Hello, World!" } # Hello, World! と3行続いて表示される。
0.times { puts "Hello, World!" } # 何も表示されない。
5.times {|n| print n } # 01234 と表示される。
//}
@see Integer#upto, Integer#downto,... -
Integer
# **(other) -> Numeric (63025.0) -
算術演算子。冪(べき乗)を計算します。
算術演算子。冪(べき乗)を計算します。
@param other 二項演算の右側の引数(対象)
@param modulo 指定すると、計算途中に巨大な値を生成せずに (self**other) % modulo と同じ結果を返します。
@return 計算結果
@raise TypeError 2引数 pow で Integer 以外を指定した場合に発生します。
@raise RangeError 2引数 pow で other に負の数を指定した場合に発生します。
//emlist[][ruby]{
2 ** 3 # => 8
2 ** 0 # => 1
0 ** 0 # => 1
... -
Integer
# pow(other) -> Numeric (63025.0) -
算術演算子。冪(べき乗)を計算します。
算術演算子。冪(べき乗)を計算します。
@param other 二項演算の右側の引数(対象)
@param modulo 指定すると、計算途中に巨大な値を生成せずに (self**other) % modulo と同じ結果を返します。
@return 計算結果
@raise TypeError 2引数 pow で Integer 以外を指定した場合に発生します。
@raise RangeError 2引数 pow で other に負の数を指定した場合に発生します。
//emlist[][ruby]{
2 ** 3 # => 8
2 ** 0 # => 1
0 ** 0 # => 1
... -
Integer
# fdiv(other) -> Numeric (63022.0) -
self を other で割った商を Float で返します。 ただし Complex が関わる場合は例外です。 その場合も成分は Float になります。
self を other で割った商を Float で返します。
ただし Complex が関わる場合は例外です。
その場合も成分は Float になります。
@param other self を割る数を指定します。
例:
654321.fdiv(13731) # => 47.652829364212366
654321.fdiv(13731.24) # => 47.65199646936475
-1234567890987654321.fdiv(13731) # => -89910996357705.52
-1234567890987654... -
Integer
# %(other) -> Numeric (63004.0) -
算術演算子。剰余を計算します。
算術演算子。剰余を計算します。
//emlist[][ruby]{
13 % 4 # => 1
13 % -4 # => -3
-13 % 4 # => 3
-13 % -4 # => -1
//}
@param other 二項演算の右側の引数(対象)
@return 計算結果 -
Integer
# *(other) -> Numeric (63004.0) -
算術演算子。積を計算します。
算術演算子。積を計算します。
@param other 二項演算の右側の引数(対象)
@return 計算結果
//emlist[][ruby]{
2 * 3 # => 6
//} -
Integer
# +(other) -> Numeric (63004.0) -
算術演算子。和を計算します。
算術演算子。和を計算します。
@param other 二項演算の右側の引数(対象)
@return 計算結果
//emlist[][ruby]{
3 + 4 # => 7
//} -
Integer
# -(other) -> Numeric (63004.0) -
算術演算子。差を計算します。
算術演算子。差を計算します。
@param other 二項演算の右側の引数(対象)
@return 計算結果
//emlist[][ruby]{
4 - 1 #=> 3
//} -
Integer
# <(other) -> bool (63004.0) -
比較演算子。数値として小さいか判定します。
比較演算子。数値として小さいか判定します。
@param other 比較対象の数値
@return self よりも other が大きい場合 true を返します。
そうでなければ false を返します。
//emlist[][ruby]{
1 < 1 # => false
1 < 2 # => true
//} -
Integer
# <=(other) -> bool (63004.0) -
比較演算子。数値として等しいまたは小さいか判定します。
比較演算子。数値として等しいまたは小さいか判定します。
@param other 比較対象の数値
@return self よりも other の方が大きい場合か、
両者が等しい場合 true を返します。
そうでなければ false を返します。
//emlist[][ruby]{
1 <= 0 # => false
1 <= 1 # => true
1 <= 2 # => true
//} -
Integer
# <=>(other) -> -1 | 0 | 1 | nil (63004.0) -
self と other を比較して、self が大きい時に1、等しい時に 0、小さい時 に-1、比較できない時に nil を返します。
self と other を比較して、self が大きい時に1、等しい時に 0、小さい時
に-1、比較できない時に nil を返します。
@param other 比較対象の数値
@return -1 か 0 か 1 か nil のいずれか
//emlist[][ruby]{
1 <=> 2 # => -1
1 <=> 1 # => 0
2 <=> 1 # => 1
2 <=> '' # => nil
//} -
Integer
# ==(other) -> bool (63004.0) -
比較演算子。数値として等しいか判定します。
比較演算子。数値として等しいか判定します。
@param other 比較対象の数値
@return self と other が等しい場合 true を返します。
そうでなければ false を返します。
//emlist[][ruby]{
1 == 2 # => false
1 == 1.0 # => true
//} -
Integer
# ===(other) -> bool (63004.0) -
比較演算子。数値として等しいか判定します。
比較演算子。数値として等しいか判定します。
@param other 比較対象の数値
@return self と other が等しい場合 true を返します。
そうでなければ false を返します。
//emlist[][ruby]{
1 == 2 # => false
1 == 1.0 # => true
//} -
Integer
# >(other) -> bool (63004.0) -
比較演算子。数値として大きいか判定します。
比較演算子。数値として大きいか判定します。
@param other 比較対象の数値
@return self よりも other の方が小さい場合 true を返します。
そうでなければ false を返します。
//emlist[][ruby]{
1 > 0 # => true
1 > 1 # => false
//} -
Integer
# >=(other) -> bool (63004.0) -
比較演算子。数値として等しいまたは大きいか判定します。
比較演算子。数値として等しいまたは大きいか判定します。
@param other 比較対象の数値
@return self よりも other の方が小さい場合か、
両者が等しい場合 true を返します。
そうでなければ false を返します。
//emlist[][ruby]{
1 >= 0 # => true
1 >= 1 # => true
1 >= 2 # => false
//} -
Integer
# chr -> String (63004.0) -
self を文字コードとして見た時に、引数で与えたエンコーディング encoding に対応する文字を返します。
self を文字コードとして見た時に、引数で与えたエンコーディング encoding に対応する文字を返します。
//emlist[][ruby]{
p 65.chr
# => "A"
p 12354.chr
# => `chr': 12354 out of char range (RangeError)
p 12354.chr(Encoding::UTF_8)
# => "あ"
p 12354.chr(Encoding::EUC_JP)
# => RangeError: invalid codepoint 0x3042 in EUC-JP
//}
引数無しで呼ばれた場合は self ... -
Integer
# chr(encoding) -> String (63004.0) -
self を文字コードとして見た時に、引数で与えたエンコーディング encoding に対応する文字を返します。
self を文字コードとして見た時に、引数で与えたエンコーディング encoding に対応する文字を返します。
//emlist[][ruby]{
p 65.chr
# => "A"
p 12354.chr
# => `chr': 12354 out of char range (RangeError)
p 12354.chr(Encoding::UTF_8)
# => "あ"
p 12354.chr(Encoding::EUC_JP)
# => RangeError: invalid codepoint 0x3042 in EUC-JP
//}
引数無しで呼ばれた場合は self ... -
Integer
# even? -> bool (63004.0) -
自身が偶数であれば真を返します。 そうでない場合は偽を返します。
自身が偶数であれば真を返します。
そうでない場合は偽を返します。
//emlist[][ruby]{
10.even? # => true
5.even? # => false
//} -
Integer
# inspect(base=10) -> String (63004.0) -
整数を 10 進文字列表現に変換します。
整数を 10 進文字列表現に変換します。
引数を指定すれば、それを基数とした文字列表
現に変換します。
//emlist[][ruby]{
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
# modulo(other) -> Numeric (63004.0) -
算術演算子。剰余を計算します。
算術演算子。剰余を計算します。
//emlist[][ruby]{
13 % 4 # => 1
13 % -4 # => -3
-13 % 4 # => 3
-13 % -4 # => -1
//}
@param other 二項演算の右側の引数(対象)
@return 計算結果 -
Integer
# odd? -> bool (63004.0) -
自身が奇数であれば真を返します。 そうでない場合は偽を返します。
自身が奇数であれば真を返します。
そうでない場合は偽を返します。
//emlist[][ruby]{
5.odd? # => true
10.odd? # => false
//} -
Integer
# prime? -> bool (63004.0) -
自身が素数である場合、真を返します。 そうでない場合は偽を返します。
自身が素数である場合、真を返します。
そうでない場合は偽を返します。
//emlist[例][ruby]{
require 'prime'
1.prime? # => false
2.prime? # => true
//}
@see Prime#prime? -
Integer
# rationalize -> Rational (63004.0) -
自身を Rational に変換します。
自身を Rational に変換します。
@param eps 許容する誤差
引数 eps は常に無視されます。
//emlist[][ruby]{
2.rationalize # => (2/1)
2.rationalize(100) # => (2/1)
2.rationalize(0.1) # => (2/1)
//} -
Integer
# rationalize(eps) -> Rational (63004.0) -
自身を Rational に変換します。
自身を Rational に変換します。
@param eps 許容する誤差
引数 eps は常に無視されます。
//emlist[][ruby]{
2.rationalize # => (2/1)
2.rationalize(100) # => (2/1)
2.rationalize(0.1) # => (2/1)
//} -
Integer
# to _ d -> BigDecimal (63004.0) -
自身を BigDecimal に変換します。BigDecimal(self) と同じです。
自身を BigDecimal に変換します。BigDecimal(self) と同じです。
@return BigDecimal に変換したオブジェクト -
Integer
# to _ f -> Float (63004.0) -
self を浮動小数点数(Float)に変換します。
self を浮動小数点数(Float)に変換します。
self が Float の範囲に収まらない場合、Float::INFINITY を返します。
//emlist[][ruby]{
1.to_f # => 1.0
(Float::MAX.to_i * 2).to_f # => Infinity
(-Float::MAX.to_i * 2).to_f # => -Infinity
//} -
Integer
# to _ i -> self (63004.0) -
self を返します。
self を返します。
//emlist[][ruby]{
10.to_i # => 10
//} -
Integer
# to _ int -> self (63004.0) -
self を返します。
self を返します。
//emlist[][ruby]{
10.to_i # => 10
//} -
Integer
# to _ r -> Rational (63004.0) -
自身を Rational に変換します。
自身を Rational に変換します。
//emlist[][ruby]{
1.to_r # => (1/1)
(1<<64).to_r # => (18446744073709551616/1)
//} -
Integer
# to _ s(base=10) -> String (63004.0) -
整数を 10 進文字列表現に変換します。
整数を 10 進文字列表現に変換します。
引数を指定すれば、それを基数とした文字列表
現に変換します。
//emlist[][ruby]{
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 以外の数値を指定した場合に発生します。 -
Numeric
# integer? -> bool (18391.0) -
自身が Integer かそのサブクラスのインスタンスの場合にtrue を返し ます。そうでない場合に false を返します。
自身が Integer かそのサブクラスのインスタンスの場合にtrue を返し
ます。そうでない場合に false を返します。
Numeric のサブクラスは、このメソッドを適切に再定義しなければなりません。
//emlist[例][ruby]{
(1.0).integer? #=> false
(1).integer? #=> true
//}
@see Numeric#real? -
Gem
:: QuickLoader # calculate _ integers _ for _ gem _ version (18304.0) -
prelude.c で定義されている内部用のメソッドです。
prelude.c で定義されている内部用のメソッドです。 -
JSON
:: Generator :: GeneratorMethods :: Integer # to _ json(state _ or _ hash = nil) -> String (9004.0) -
自身から生成した JSON 形式の文字列を返します。
自身から生成した JSON 形式の文字列を返します。
@param state_or_hash 生成する JSON 形式の文字列をカスタマイズするため
に JSON::State のインスタンスか、
JSON::State.new の引数と同じ Hash を
指定します。
//emlist[例][ruby]{
require "json"
10.to_json # => "10"
//} -
BigDecimal
# split -> [Integer , String , Integer , Integer] (913.0) -
BigDecimal 値を 0.xxxxxxx*10**n と表現したときに、 符号 (NaNのときは 0、それ以外は+1か-1になります)、 仮数部分の文字列("xxxxxxx")と、基数(10)、更に指数 n を配列で返します。
BigDecimal 値を 0.xxxxxxx*10**n と表現したときに、
符号 (NaNのときは 0、それ以外は+1か-1になります)、
仮数部分の文字列("xxxxxxx")と、基数(10)、更に指数 n を配列で返します。
//emlist[][ruby]{
require "bigdecimal"
a = BigDecimal("3.14159265")
f, x, y, z = a.split
//}
とすると、f = 1、x = "314159265"、y = 10、z = 1 になります。
従って、以下のようにする事で Float に変換することができます。
//em... -
REXML
:: ParseException # context -> [Integer , Integer , Integer] (913.0) -
パースエラーが起きた(XML上の)場所を返します。
パースエラーが起きた(XML上の)場所を返します。
要素3個の配列で、
[position, lineno, line]
という形で返します。
position, line は
REXML::ParseException#position
REXML::ParseException#line
と同じ値です。
lineno は IO#lineno が返す意味での行数です。
通常は line と同じ値です。 -
Matrix
# find _ index(selector = :all) {|e| . . . } -> [Integer , Integer] | nil (628.0) -
指定した値と一致する要素の位置を [row, column] という配列で返します。 ブロックを与えた場合は各要素を引数としてブロックを呼び出し、 返り値が真であった要素の位置を返します。
指定した値と一致する要素の位置を [row, column] という配列で返します。
ブロックを与えた場合は各要素を引数としてブロックを呼び出し、
返り値が真であった要素の位置を返します。
複数の位置で値が一致する/ブロックが真を返す、場合は最初
に見つかった要素の位置を返します。
selector で行列のどの部分を探すかを指定します。この引数の意味は
Matrix#each を参照してください。
//emlist[例][ruby]{
require 'matrix'
Matrix[ [1,2], [3,4] ].index(&:even?) # => [0, 1]
Matrix[ ... -
Matrix
# find _ index(value , selector = :all) -> [Integer , Integer] | nil (628.0) -
指定した値と一致する要素の位置を [row, column] という配列で返します。 ブロックを与えた場合は各要素を引数としてブロックを呼び出し、 返り値が真であった要素の位置を返します。
指定した値と一致する要素の位置を [row, column] という配列で返します。
ブロックを与えた場合は各要素を引数としてブロックを呼び出し、
返り値が真であった要素の位置を返します。
複数の位置で値が一致する/ブロックが真を返す、場合は最初
に見つかった要素の位置を返します。
selector で行列のどの部分を探すかを指定します。この引数の意味は
Matrix#each を参照してください。
//emlist[例][ruby]{
require 'matrix'
Matrix[ [1,2], [3,4] ].index(&:even?) # => [0, 1]
Matrix[ ... -
Matrix
# index(selector = :all) {|e| . . . } -> [Integer , Integer] | nil (628.0) -
指定した値と一致する要素の位置を [row, column] という配列で返します。 ブロックを与えた場合は各要素を引数としてブロックを呼び出し、 返り値が真であった要素の位置を返します。
指定した値と一致する要素の位置を [row, column] という配列で返します。
ブロックを与えた場合は各要素を引数としてブロックを呼び出し、
返り値が真であった要素の位置を返します。
複数の位置で値が一致する/ブロックが真を返す、場合は最初
に見つかった要素の位置を返します。
selector で行列のどの部分を探すかを指定します。この引数の意味は
Matrix#each を参照してください。
//emlist[例][ruby]{
require 'matrix'
Matrix[ [1,2], [3,4] ].index(&:even?) # => [0, 1]
Matrix[ ... -
Matrix
# index(value , selector = :all) -> [Integer , Integer] | nil (628.0) -
指定した値と一致する要素の位置を [row, column] という配列で返します。 ブロックを与えた場合は各要素を引数としてブロックを呼び出し、 返り値が真であった要素の位置を返します。
指定した値と一致する要素の位置を [row, column] という配列で返します。
ブロックを与えた場合は各要素を引数としてブロックを呼び出し、
返り値が真であった要素の位置を返します。
複数の位置で値が一致する/ブロックが真を返す、場合は最初
に見つかった要素の位置を返します。
selector で行列のどの部分を探すかを指定します。この引数の意味は
Matrix#each を参照してください。
//emlist[例][ruby]{
require 'matrix'
Matrix[ [1,2], [3,4] ].index(&:even?) # => [0, 1]
Matrix[ ... -
MatchData
# offset(n) -> [Integer , Integer] | [nil , nil] (616.0) -
n 番目の部分文字列のオフセットの配列 [start, end] を返 します。
n 番目の部分文字列のオフセットの配列 [start, end] を返
します。
//emlist[例][ruby]{
[ self.begin(n), self.end(n) ]
//}
と同じです。n番目の部分文字列がマッチしていなければ
[nil, nil] を返します。
@param n 部分文字列を指定する数値
@raise IndexError 範囲外の n を指定した場合に発生します。
@see MatchData#begin, MatchData#end -
MatchData
# offset(name) -> [Integer , Integer] | [nil , nil] (616.0) -
name という名前付きグループに対応する部分文字列のオフセットの配列 [start, end] を返 します。
name という名前付きグループに対応する部分文字列のオフセットの配列 [start, end] を返
します。
//emlist[例][ruby]{
[ self.begin(name), self.end(name) ]
//}
と同じです。nameの名前付きグループにマッチした部分文字列がなければ
[nil, nil] を返します。
@param name 名前(シンボルか文字列)
@raise IndexError 正規表現中で定義されていない name を指定した場合に発生します。
//emlist[例][ruby]{
/(?<year>\d{4})年(?<month>\... -
BasicSocket
# getpeereid -> [Integer , Integer] (610.0) -
Unix ドメインソケットにおいて接続相手の euid と egid を 返します。
Unix ドメインソケットにおいて接続相手の euid と egid を
返します。
配列の最初の要素が euid, 2番目の要素が 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 ... -
BigDecimal
# precs -> [Integer , Integer] (610.0) -
self の有効数字と最大有効数字の配列を返します。
self の有効数字と最大有効数字の配列を返します。 -
IO
# winsize -> [Integer , Integer] (610.0) -
端末のサイズを [rows, columns] で返します。
端末のサイズを [rows, columns] で返します。 -
OpenSSL
:: OCSP :: BasicResponse # status -> [[OpenSSL :: OCSP :: CertificateId , Integer , Integer , Time|nil , Time , Time|nil , [OpenSSL :: X509 :: Extension]]] (610.0) -
証明書の状態の問い合わせの結果を返します。
証明書の状態の問い合わせの結果を返します。
この返り値には複数の問い合わせ結果が含まれています。
個々の結果は以下の内容の配列です。
[ 問い合わせの CertificateId オブジェクト,
ステータスコード,
失効理由コード,
失効時刻,
最終更新時刻,
次回更新時刻,
拡張領域 ]
ステータスコードはいかのいずれかの値を取ります
* OpenSSL::OCSP::V_CERTSTATUS_GOOD 正常
* OpenSSL::OCSP::V_CERTSTATUS_REVOKED 失効
* OpenSSL::OCSP::... -
OpenSSL
:: SSL :: SSLContext # ciphers -> [[String , String , Integer , Integer]] (610.0) -
利用可能な共通鍵暗号の種類を配列で返します。
利用可能な共通鍵暗号の種類を配列で返します。
配列の各要素は以下のような配列です
[暗号方式の名前の文字列, 利用可能なSSL/TLSのバージョン文字列, 鍵長(ビット数), アルゴリズムのビット長]
例:
require 'openssl'
ctx = OpenSSL::SSL::SSLContext.new('TLSv1')
ctx.ciphers
# => [["DHE-RSA-AES256-SHA", "TLSv1/SSLv3", 256, 256],
# ["DHE-DSS-AES256-SHA", "TLSv1/SSLv3", 256, 256]... -
OpenSSL
:: SSL :: SSLSocket # cipher -> [String , String , Integer , Integer] (610.0) -
現在実際に使われている暗号の情報を配列で返します。
現在実際に使われている暗号の情報を配列で返します。
返される配列の形式は以下の例のように [暗号名, TLS/SSLのバージョン, 鍵長, アルゴリズムで使われる bit 数] となります。
["DES-CBC3-SHA", "TLSv1/SSLv3", 168, 168]
OpenSSL::SSL::SSLSocket#connect や OpenSSL::SSL::SSLSocket#accept
で SSL/TLS ハンドシェイクを行う前にこのメソッドを呼ぶと nil を返します。 -
Prime
# prime _ division(value , generator= Prime :: Generator23 . new) -> [[Integer , Integer]] (610.0) -
与えられた整数を素因数分解します。
与えられた整数を素因数分解します。
@param value 素因数分解する任意の整数を指定します。
@param generator 素数生成器のインスタンスを指定します。
@return 素因数とその指数から成るペアを要素とする配列です。つまり、戻り値の各要素は2要素の配列 [n,e] であり、それぞれの内部配列の第1要素 n は value の素因数、第2要素は n**e が value を割り切る最大の自然数 e です。
@raise ZeroDivisionError 与えられた数値がゼロである場合に発生します。
//emlist[例][ruby]{
require 'p... -
Ripper
:: Lexer # lex -> [[Integer , Integer] , Symbol , String , Ripper :: Lexer :: State] (610.0) -
自身の持つ Ruby プログラムをトークンに分割し、そのリストを返します。
自身の持つ Ruby プログラムをトークンに分割し、そのリストを返します。
ライブラリ内部で使用します。 Ripper.lex を使用してください。 -
Ripper
:: Lexer # parse -> [[Integer , Integer] , Symbol , String , Ripper :: Lexer :: State] (610.0) -
自身の持つ Ruby プログラムをトークンに分割し、そのリストを返します。た だし Ripper::Lexer#lex と違い、結果をソートしません。
自身の持つ Ruby プログラムをトークンに分割し、そのリストを返します。た
だし Ripper::Lexer#lex と違い、結果をソートしません。
ライブラリ内部で使用します。 -
WEBrick
:: HTTPServlet :: DefaultFileHandler # prepare _ range(range , filesize) -> [Integer , Integer] (610.0) -
WEBrick::HTTPServlet::DefaultFileHandler#make_partial_content で利用する範囲情報を生成して返します。
WEBrick::HTTPServlet::DefaultFileHandler#make_partial_content で利用する範囲情報を生成して返します。
@param range 2 要素の配列を指定します。
@param filesize ファイルサイズを指定します。 -
Net
:: FTP :: MLSxEntry # facts -> { String => String|Integer|Time } (379.0) -
そのエントリの「facts」を返します。
そのエントリの「facts」を返します。
facts とはそのエントリに関するファイルサイズなどの様々な情報です。
Net::FTP はこの情報を文字列をキーとするハッシュテーブルで
返します。
標準では以下のような facts が定義されています。これらの facts には
対応するメソッドが定義されています。すべてのサーバでこれら
の facts がすべて実装されているわけではありません。
3659 では
modify, perm, type, size, unique はすべてのサーバで
対応すべき(SHOULD)、とされています。
* "modify" : 変更時刻 (Ti... -
IRB
:: Context # eval _ history -> Integer | nil (373.0) -
実行結果の履歴の最大保存件数を Integer か nil で返します。
実行結果の履歴の最大保存件数を Integer か nil で返します。
@return 履歴の最大保存件数を Integer か nil で返します。0 を返し
た場合は無制限に保存します。nil を返した場合は追加の保存は行いません。
@see IRB::Context#eval_history= -
IRB
:: Context # save _ history -> Integer | nil (373.0) -
履歴の最大保存件数を Integer か nil で返します。
履歴の最大保存件数を Integer か nil で返します。
@return 履歴の最大保存件数を Integer か nil で返します。0 以下や
nil を返した場合は追加の保存は行いません。
@see lib:irb#history -
Object
# to _ int -> Integer (373.0) -
オブジェクトの Integer への暗黙の変換が必要なときに内部で呼ばれます。 デフォルトでは定義されていません。
オブジェクトの Integer への暗黙の変換が必要なときに内部で呼ばれます。
デフォルトでは定義されていません。
説明のためここに記載してありますが、
このメソッドは実際には Object クラスには定義されていません。
必要に応じてサブクラスで定義すべきものです。
このメソッドを定義する条件は、
* 整数が使われるすべての場面で代置可能であるような、
* 整数そのものとみなせるようなもの
という厳しいものになっています。
//emlist[][ruby]{
class Foo
def to_int
1
end
end
ary = [:a, :b, :c]
p(... -
OpenSSL
:: BN # to _ i -> Integer (358.0) -
自身を Integer のインスタンスに変換します。
自身を Integer のインスタンスに変換します。
@raise OpenSSL::BNError 変換に失敗した場合に発生します -
OpenSSL
:: BN # to _ int -> Integer (358.0) -
自身を Integer のインスタンスに変換します。
自身を Integer のインスタンスに変換します。
@raise OpenSSL::BNError 変換に失敗した場合に発生します