ライブラリ
- ビルトイン (1690)
クラス
-
ARGF
. class (81) - Array (155)
- BasicObject (14)
- Bignum (33)
- Binding (6)
- Class (5)
- Complex (42)
- Dir (13)
- Encoding (7)
-
Encoding
:: Converter (17) -
Encoding
:: InvalidByteSequenceError (7) -
Encoding
:: UndefinedConversionError (5) - Enumerator (15)
-
Enumerator
:: Lazy (29) -
Enumerator
:: Yielder (2) - Exception (10)
- FalseClass (5)
- Fiber (1)
- File (12)
-
File
:: Stat (42) - Fixnum (35)
- Float (41)
- Hash (75)
- IO (102)
- Integer (66)
- LoadError (1)
- LocalJumpError (2)
- MatchData (24)
- Method (21)
- Module (75)
- Mutex (7)
- NameError (2)
- NilClass (13)
- NoMethodError (1)
- Numeric (45)
- Object (69)
-
ObjectSpace
:: WeakMap (2) - Proc (15)
-
Process
:: Status (15) -
Process
:: Tms (8) - Random (10)
- Range (31)
- Rational (25)
- Regexp (17)
-
RubyVM
:: InstructionSequence (10) - SignalException (2)
- StopIteration (1)
- String (165)
- Struct (21)
- Symbol (31)
- SystemCallError (1)
- SystemExit (2)
- Thread (32)
-
Thread
:: Backtrace :: Location (7) - ThreadGroup (4)
- Time (55)
- TracePoint (16)
- TrueClass (5)
- UnboundMethod (14)
- UncaughtThrowError (3)
モジュール
- Comparable (6)
- Enumerable (111)
- GC (1)
キーワード
- ! (1)
- != (1)
- !~ (1)
- % (6)
- & (8)
- * (9)
- ** (6)
- + (9)
- +@ (1)
- - (9)
- -@ (6)
-
/ (6) - < (6)
- << (7)
- <= (6)
- <=> (13)
- == (22)
- === (9)
- =~ (4)
- > (6)
- >= (6)
- >> (4)
- [] (27)
- []= (14)
- ^ (6)
-
_ _ id _ _ (1) -
_ _ send _ _ (2) -
_ dump (1) -
_ load (1) -
abort
_ on _ exception (1) -
abort
_ on _ exception= (1) - abs (6)
- abs2 (2)
-
absolute
_ path (2) - add (1)
-
add
_ trace _ func (1) - advise (1)
-
alias
_ method (1) - alive? (1)
- all? (2)
- allocate (1)
- ancestors (1)
- angle (3)
- any? (4)
-
append
_ features (1) - arg (3)
- args (1)
- argv (1)
- arity (3)
-
ascii
_ compatible? (1) -
ascii
_ only? (1) - asctime (1)
- assoc (2)
- at (1)
- atime (2)
- attr (3)
-
attr
_ accessor (1) -
attr
_ reader (1) -
attr
_ writer (1) - autoclose= (1)
- autoclose? (1)
- autoload (1)
- autoload? (1)
- b (1)
- backtrace (2)
-
backtrace
_ locations (3) -
base
_ label (2) - begin (2)
- between? (2)
- bind (1)
- binding (2)
- binmode (2)
- binmode? (2)
- birthtime (2)
-
bit
_ length (3) - blksize (1)
- blockdev? (1)
- blocks (1)
- bsearch (4)
- bytes (7)
- bytesize (1)
- byteslice (3)
- call (3)
-
callee
_ id (1) - capitalize (2)
- capitalize! (1)
- captures (1)
- casecmp (2)
- casefold? (1)
- cause (1)
- ceil (4)
- center (1)
- chardev? (1)
- chars (6)
- chmod (1)
- chomp (1)
- chomp! (1)
- chop (1)
- chop! (1)
- chown (1)
- chr (3)
- chunk (3)
-
chunk
_ while (1) - clamp (1)
- class (1)
-
class
_ eval (2) -
class
_ exec (1) -
class
_ variable _ defined? (1) -
class
_ variable _ get (1) -
class
_ variable _ set (1) -
class
_ variables (1) - clear (3)
- clone (6)
- close (3)
-
close
_ on _ exec= (1) -
close
_ on _ exec? (1) -
close
_ read (1) -
close
_ write (1) - closed? (2)
- codepoints (6)
- coerce (3)
- collect (5)
- collect! (2)
-
collect
_ concat (3) - combination (2)
- compact (1)
- compact! (1)
-
compare
_ by _ identity (1) -
compare
_ by _ identity? (1) - concat (2)
- conj (2)
- conjugate (2)
-
const
_ defined? (1) -
const
_ get (1) -
const
_ missing (1) -
const
_ set (1) - constants (1)
- convert (2)
- convpath (1)
- coredump? (1)
- count (7)
- cover? (1)
- crypt (1)
- cstime (1)
- cstime= (1)
- ctime (3)
- curry (4)
- cutime (1)
- cutime= (1)
- cycle (4)
- day (1)
- default (2)
- default= (1)
-
default
_ proc (1) -
default
_ proc= (1) -
define
_ method (2) -
define
_ singleton _ method (2) -
defined
_ class (1) - delete (5)
- delete! (1)
-
delete
_ at (1) -
delete
_ if (4) - denominator (5)
-
destination
_ encoding (3) -
destination
_ encoding _ name (2) - detect (2)
- dev (1)
-
dev
_ major (1) -
dev
_ minor (1) - digits (2)
- directory? (1)
- disable (2)
- disasm (1)
- disassemble (1)
- display (1)
- div (4)
- divmod (5)
- downcase (2)
- downcase! (1)
- downto (2)
- drop (3)
-
drop
_ while (5) - dst? (1)
- dummy? (1)
- dump (1)
- dup (4)
- each (24)
-
each
_ byte (6) -
each
_ char (6) -
each
_ codepoint (6) -
each
_ cons (2) -
each
_ entry (2) -
each
_ index (2) -
each
_ key (2) -
each
_ line (12) -
each
_ pair (4) -
each
_ slice (2) -
each
_ value (2) -
each
_ with _ index (2) -
each
_ with _ object (2) - empty? (4)
- enable (2)
- enabled? (1)
- enclose (1)
- enclosed? (1)
- encode (3)
- encode! (2)
- encoding (3)
- end (2)
-
end
_ with? (1) - entries (1)
-
enum
_ for (4) - eof (2)
- eof? (2)
- eql? (14)
- equal? (4)
- errno (1)
-
error
_ bytes (1) -
error
_ char (1) - eval (2)
- even? (3)
- event (1)
- exception (2)
-
exclude
_ end? (1) - executable? (1)
-
executable
_ real? (1) - exit (1)
-
exit
_ value (1) - exited? (1)
- exitstatus (1)
- extend (1)
-
extend
_ object (1) - extended (1)
-
external
_ encoding (2) - fcntl (1)
- fdatasync (1)
- fdiv (6)
- feed (1)
- fetch (6)
- file (1)
- file? (1)
- filename (1)
- fileno (3)
- fill (6)
- find (2)
-
find
_ all (3) -
find
_ index (6) - finish (1)
- finite? (1)
- first (6)
-
first
_ lineno (1) -
fixed
_ encoding? (1) -
flat
_ map (3) - flatten (2)
- flatten! (1)
- flock (1)
- floor (4)
- flush (1)
- force (1)
-
force
_ encoding (1) - freeze (2)
- friday? (1)
- frozen? (1)
- fsync (1)
- ftype (1)
-
garbage
_ collect (1) - gcd (1)
- gcdlcm (1)
- getbyte (3)
- getc (2)
- getgm (1)
- getlocal (2)
- gets (6)
- getutc (1)
- gid (1)
- gmt? (1)
-
gmt
_ offset (1) - gmtime (1)
- gmtoff (1)
- grep (3)
-
grep
_ v (2) - group (1)
-
group
_ by (2) - grpowned? (1)
- gsub (4)
- gsub! (4)
-
has
_ key? (1) -
has
_ value? (1) - hash (15)
- hex (1)
- hour (1)
- i (1)
- id2name (1)
- imag (2)
- imaginary (2)
- include (1)
- include? (6)
- included (1)
-
included
_ modules (1) -
incomplete
_ input? (1) - index (5)
- infinite? (1)
- inherited (1)
- initialize (1)
-
initialize
_ copy (1) - inject (3)
- ino (1)
-
inplace
_ mode (1) -
inplace
_ mode= (1) - insert (2)
-
insert
_ output (1) - inspect (31)
-
instance
_ eval (2) -
instance
_ exec (1) -
instance
_ method (1) -
instance
_ methods (1) -
instance
_ of? (1) -
instance
_ variable _ defined? (1) -
instance
_ variable _ get (1) -
instance
_ variable _ set (1) -
instance
_ variables (1) - integer? (2)
- intern (2)
-
internal
_ encoding (2) - invert (1)
- ioctl (1)
-
is
_ a? (1) - isatty (1)
- isdst (1)
- itself (1)
- join (3)
-
keep
_ if (4) - key (1)
- key? (2)
- keys (2)
- kill (1)
-
kind
_ of? (1) - label (2)
- lambda? (1)
- last (4)
-
last
_ error (1) - lazy (2)
- lcm (1)
- left (1)
- length (6)
- lineno (4)
- lineno= (2)
- lines (14)
- list (1)
- ljust (1)
-
local
_ variable _ defined? (1) -
local
_ variable _ get (1) -
local
_ variable _ set (1) -
local
_ variables (1) - localtime (2)
- lock (1)
- locked? (1)
- lstat (1)
- lstrip (1)
- lstrip! (1)
- magnitude (6)
- map (5)
- map! (2)
-
marshal
_ dump (4) -
marshal
_ load (2) - match (5)
- max (8)
-
max
_ by (4) - mday (1)
- member? (3)
- members (1)
- merge (2)
- merge! (2)
- method (1)
-
method
_ added (1) -
method
_ defined? (1) -
method
_ id (1) -
method
_ missing (1) -
method
_ removed (1) -
method
_ undefined (1) - methods (1)
- min (9)
-
min
_ by (4) - minmax (2)
-
minmax
_ by (2) - mode (1)
-
module
_ eval (2) -
module
_ exec (1) -
module
_ function (1) - modulo (5)
- mon (1)
- monday? (1)
- month (1)
- mtime (2)
- name (5)
-
named
_ captures (2) - names (3)
- nan? (1)
- new (1)
- next (4)
- next! (1)
-
next
_ float (1) -
next
_ values (1) - nil? (2)
- nlink (1)
- none? (2)
- nonzero? (1)
- nsec (1)
- numerator (5)
-
object
_ id (1) - oct (1)
- odd? (3)
- offset (2)
- one? (2)
- ord (2)
-
original
_ name (2) - owned? (2)
- owner (2)
- pack (1)
- parameters (3)
- partition (3)
- path (7)
- peek (1)
-
peek
_ values (1) -
pending
_ interrupt? (1) - permutation (2)
- phase (3)
- pid (2)
- pipe? (1)
- polar (2)
- pop (2)
- pos (3)
- pos= (3)
-
post
_ match (1) - pow (2)
-
pre
_ match (1) - pred (1)
- prepend (2)
-
prepend
_ features (1) - prepended (1)
-
prev
_ float (1) -
primitive
_ convert (4) -
primitive
_ errinfo (1) - print (2)
- printf (2)
- priority (1)
- priority= (1)
- private (1)
-
private
_ class _ method (1) -
private
_ constant (1) -
private
_ instance _ methods (1) -
private
_ method _ defined? (1) -
private
_ methods (1) - product (2)
- protected (1)
-
protected
_ instance _ methods (1) -
protected
_ method _ defined? (1) -
protected
_ methods (1) - public (1)
-
public
_ class _ method (1) -
public
_ constant (1) -
public
_ instance _ method (1) -
public
_ instance _ methods (1) -
public
_ method (1) -
public
_ method _ defined? (1) -
public
_ methods (1) -
public
_ send (2) - push (1)
- putback (2)
- putc (2)
- puts (2)
- quo (3)
- raise (1)
-
raised
_ exception (1) - rand (3)
- rassoc (2)
- rationalize (9)
- rdev (1)
-
rdev
_ major (1) -
rdev
_ minor (1) - read (3)
-
read
_ nonblock (2) - readable? (1)
-
readable
_ real? (1) -
readagain
_ bytes (1) - readbyte (2)
- readchar (2)
- readline (6)
- readlines (6)
- readpartial (2)
- real (2)
- real? (2)
- reason (1)
- receiver (2)
- rect (2)
- rectangular (2)
- reduce (3)
- refine (1)
- regexp (1)
- rehash (1)
- reject (7)
- reject! (4)
- remainder (3)
-
remove
_ class _ variable (1) -
remove
_ const (1) -
remove
_ instance _ variable (1) -
remove
_ method (1) - reopen (3)
-
repeated
_ combination (2) -
repeated
_ permutation (2) - replace (3)
- replacement (1)
- replacement= (1)
- replicate (1)
-
respond
_ to? (1) -
respond
_ to _ missing? (1) - result (1)
- resume (1)
-
return
_ value (1) - reverse (2)
- reverse! (2)
-
reverse
_ each (4) - rewind (4)
- rindex (4)
- rjust (1)
- rotate (1)
- rotate! (1)
- round (5)
- rpartition (1)
- rstrip (1)
- rstrip! (1)
- run (1)
-
safe
_ level (1) - sample (4)
- saturday? (1)
- scan (2)
- scrub (3)
- scrub! (3)
- sec (1)
- seed (1)
- seek (3)
- select (9)
- select! (4)
- self (1)
- send (2)
-
set
_ backtrace (1) -
set
_ encoding (6) -
set
_ trace _ func (1) - setbyte (1)
- setgid? (1)
- setuid? (1)
- shift (3)
- shuffle (2)
- shuffle! (2)
- signaled? (1)
- signm (1)
- signo (1)
-
singleton
_ class (1) -
singleton
_ class? (1) -
singleton
_ method (1) -
singleton
_ method _ added (1) -
singleton
_ method _ removed (1) -
singleton
_ method _ undefined (1) -
singleton
_ methods (1) - size (13)
- size? (1)
- skip (1)
- sleep (1)
- slice (14)
- slice! (9)
-
slice
_ after (4) -
slice
_ before (5) -
slice
_ when (2) - socket? (1)
- sort (4)
- sort! (2)
-
sort
_ by (2) -
sort
_ by! (2) - source (1)
-
source
_ encoding (3) -
source
_ encoding _ name (2) -
source
_ location (3) - split (1)
- squeeze (1)
- squeeze! (1)
-
start
_ with? (1) - stat (1)
- state (1)
- status (2)
- step (8)
- sticky? (1)
- stime (1)
- stime= (1)
- stop? (1)
- stopped? (1)
- stopsig (1)
- store (1)
- strftime (1)
- string (1)
- strip (1)
- strip! (1)
- sub (3)
- sub! (3)
- subsec (1)
- succ (5)
- succ! (1)
- success? (2)
- sum (3)
- sunday? (1)
-
super
_ method (2) - superclass (1)
- swapcase (2)
- swapcase! (1)
- symlink? (1)
- sync (1)
- sync= (1)
- synchronize (1)
- sysread (1)
- sysseek (1)
- syswrite (1)
- tag (1)
- taint (1)
- tainted? (1)
- take (3)
-
take
_ while (6) - tap (1)
- tell (3)
- terminate (1)
- termsig (1)
-
thread
_ variable? (1) -
thread
_ variable _ get (1) -
thread
_ variable _ set (1) - thursday? (1)
- times (2)
-
to
_ a (12) -
to
_ ary (2) -
to
_ c (4) -
to
_ enum (4) -
to
_ f (9) -
to
_ h (5) -
to
_ hash (2) -
to
_ i (10) -
to
_ int (3) -
to
_ io (3) -
to
_ path (2) -
to
_ proc (4) -
to
_ r (7) -
to
_ regexp (1) -
to
_ s (30) -
to
_ str (2) -
to
_ sym (2) -
to
_ write _ io (1) - tr (1)
- tr! (1)
-
tr
_ s (1) -
tr
_ s! (1) - transpose (1)
- truncate (5)
- trust (1)
-
try
_ lock (1) - tty? (1)
- tuesday? (1)
-
tv
_ nsec (1) -
tv
_ sec (1) -
tv
_ usec (1) - uid (1)
- unbind (1)
-
undef
_ method (1) - ungetbyte (1)
- ungetc (1)
-
unicode
_ normalize (1) -
unicode
_ normalize! (1) -
unicode
_ normalized? (1) - uniq (4)
- uniq! (2)
- unlock (1)
- unpack (1)
- unshift (1)
- untaint (1)
- untrust (1)
- untrusted? (1)
- upcase (2)
- upcase! (1)
- update (2)
- upto (3)
- usec (1)
- using (1)
- utc (1)
- utc? (1)
-
utc
_ offset (1) - utime (1)
- utime= (1)
-
valid
_ encoding? (1) - value (2)
- value? (1)
- values (2)
-
values
_ at (4) - wakeup (1)
- wday (1)
- wednesday? (1)
-
with
_ index (2) -
with
_ object (2) -
world
_ readable? (1) -
world
_ writable? (1) - writable? (1)
-
writable
_ real? (1) - write (2)
-
write
_ nonblock (1) - yday (1)
- year (1)
- yield (2)
- zero? (4)
- zip (6)
- zone (1)
- | (7)
- ~ (4)
検索結果
先頭5件
-
Complex
# *(other) -> Complex (24004.0) -
積を計算します。
積を計算します。
@param other 自身に掛ける数
//emlist[例][ruby]{
Complex(1, 2) * 2 # => (2+4i)
Complex(1, 2) * Complex(2, 3) # => (-4+7i)
Complex(1, 2) * Rational(1, 2) # => ((1/2)+(1/1)*i)
//} -
Complex
# **(other) -> Complex (24004.0) -
冪(べき)乗を計算します。
冪(べき)乗を計算します。
@param other 自身を other 乗する数
//emlist[例][ruby]{
Complex('i') ** 2 # => (-1+0i)
//} -
Complex
# +(other) -> Complex (24004.0) -
和を計算します。
和を計算します。
@param other 自身に足す数
//emlist[例][ruby]{
Complex(1, 2) + Complex(2, 3) # => (3+5i)
//} -
Complex
# -(other) -> Complex (24004.0) -
差を計算します。
差を計算します。
@param other 自身から引く数
//emlist[例][ruby]{
Complex(1, 2) - Complex(2, 3) # => (-1-1i)
//} -
Complex
# -@ -> Complex (24004.0) -
自身の符号を反転させたものを返します。
自身の符号を反転させたものを返します。
//emlist[例][ruby]{
-Complex(1) # => (-1+0i)
-Complex(-1, 1) # => (1-1i)
//} -
Complex
# / (other) -> Complex (24004.0) -
商を計算します。
商を計算します。
@param other 自身を割る数
//emlist[例][ruby]{
Complex(10.0) / 3 # => (3.3333333333333335+(0/1)*i)
Complex(10) / 3 # => ((10/3)+(0/1)*i)
//}
@see Numeric#quo -
Complex
# <(other) -> bool (24004.0) -
@undef
@undef -
Complex
# <=(other) -> bool (24004.0) -
@undef
@undef -
Complex
# ==(other) -> bool (24004.0) -
数値として等しいか判定します。
数値として等しいか判定します。
@param other 自身と比較する数値
//emlist[例][ruby]{
Complex(2, 1) == Complex(1) # => false
Complex(1, 0) == Complex(1) # => true
Complex(1, 0) == 1 # => true
//} -
Complex
# >(other) -> bool (24004.0) -
@undef
@undef -
Complex
# >=(other) -> bool (24004.0) -
@undef
@undef -
Complex
# abs -> Numeric (24004.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
# abs2 -> Numeric (24004.0) -
自身の絶対値の 2 乗を返します。
自身の絶対値の 2 乗を返します。
以下の計算の結果を返します。
self.real ** 2 + self.imag ** 2
//emlist[例][ruby]{
Complex(1, 1).abs2 # => 2
Complex(1.0, 1.0).abs2 # => 2.0
Complex('1/2', '1/2').abs2 # => (1/2)
//}
@see Complex#abs -
Complex
# angle -> Float (24004.0) -
自身の偏角を[-π,π]の範囲で返します。
自身の偏角を[-π,π]の範囲で返します。
//emlist[例][ruby]{
Complex.polar(3, Math::PI/2).arg # => 1.5707963267948966
//}
非正の実軸付近での挙動に注意してください。以下の例のように虚部が 0.0 と
-0.0 では値が変わります。
//emlist[例][ruby]{
Complex(-1, 0).arg #=> 3.141592653589793
Complex(-1, -0).arg #=> 3.141592653589793
Complex(-1... -
Complex
# arg -> Float (24004.0) -
自身の偏角を[-π,π]の範囲で返します。
自身の偏角を[-π,π]の範囲で返します。
//emlist[例][ruby]{
Complex.polar(3, Math::PI/2).arg # => 1.5707963267948966
//}
非正の実軸付近での挙動に注意してください。以下の例のように虚部が 0.0 と
-0.0 では値が変わります。
//emlist[例][ruby]{
Complex(-1, 0).arg #=> 3.141592653589793
Complex(-1, -0).arg #=> 3.141592653589793
Complex(-1... -
Complex
# between?(min , max) -> bool (24004.0) -
@undef
@undef -
Complex
# clamp(range) -> object (24004.0) -
@undef
@undef -
Complex
# coerce(other) -> [Complex , Complex] (24004.0) -
other を Complex に変換して [変換後の other, self] の配列を返します。
other を Complex に変換して [変換後の other, self] の配列を返します。
@raise TypeError 変換できないオブジェクトを指定した場合に発生します。
//emlist[例][ruby]{
Complex(1).coerce(2) # => [(2+0i), (1+0i)]
//} -
Complex
# conj -> Complex (24004.0) -
自身の共役複素数を返します。
自身の共役複素数を返します。
//emlist[例][ruby]{
Complex(1, 2).conj # => (1-2i)
//} -
Complex
# conjugate -> Complex (24004.0) -
自身の共役複素数を返します。
自身の共役複素数を返します。
//emlist[例][ruby]{
Complex(1, 2).conj # => (1-2i)
//} -
Complex
# denominator -> Integer (24004.0) -
分母を返します。
分母を返します。
以下のように、実部と虚部の分母の最小公倍数を整数で返します。
1 2 3+4i <- numerator(分子)
- + -i -> ----
2 3 6 <- denominator(分母)
//emlist[例][ruby]{
Complex('1/2+2/3i').denominator # => 6
Complex(3).numerator # => 1
//}
@see Complex#numerator -
Complex
# fdiv(other) -> Complex (24004.0) -
self を other で割った商を返します。 実部と虚部が共に Float の値になります。
self を other で割った商を返します。
実部と虚部が共に Float の値になります。
@param other 自身を割る数
//emlist[例][ruby]{
Complex(11, 22).fdiv(3) # => (3.6666666666666665+7.333333333333333i)
Complex(11, 22).quo(3) # => ((11/3)+(22/3)*i)
//}
@see Complex#quo -
Complex
# imag -> Numeric (24004.0) -
自身の虚部を返します。
自身の虚部を返します。
//emlist[例][ruby]{
Complex(3, 2).imag # => 2
//}
@see Numeric#imag -
Complex
# imaginary -> Numeric (24004.0) -
自身の虚部を返します。
自身の虚部を返します。
//emlist[例][ruby]{
Complex(3, 2).imag # => 2
//}
@see Numeric#imag -
Complex
# inspect -> String (24004.0) -
自身を人間が読みやすい形の文字列表現にして返します。
自身を人間が読みやすい形の文字列表現にして返します。
//emlist[例][ruby]{
Complex(2).inspect # => "(2+0i)"
Complex('-8/6').inspect # => "((-4/3)+0i)"
Complex('1/2i').inspect # => "(0+(1/2)*i)"
Complex(0, Float::INFINITY).inspect # => "(0+Infinity*i)"
Complex(Float:... -
Complex
# magnitude -> Numeric (24004.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
# marshal _ dump -> Array (24004.0) -
Marshal.#load のためのメソッドです。 Complex::compatible#marshal_load で復元可能な配列を返します。
Marshal.#load のためのメソッドです。
Complex::compatible#marshal_load で復元可能な配列を返します。
2.0 以降では Marshal.#load で 1.8 系の Complex オブジェクト
を保存した文字列も復元できます。
[注意] Complex::compatible は通常の方法では参照する事ができません。 -
Complex
# numerator -> Complex (24004.0) -
分子を返します。
分子を返します。
//emlist[例][ruby]{
Complex('1/2+2/3i').numerator # => (3+4i)
Complex(3).numerator # => (3+0i)
//}
@see Complex#denominator -
Complex
# phase -> Float (24004.0) -
自身の偏角を[-π,π]の範囲で返します。
自身の偏角を[-π,π]の範囲で返します。
//emlist[例][ruby]{
Complex.polar(3, Math::PI/2).arg # => 1.5707963267948966
//}
非正の実軸付近での挙動に注意してください。以下の例のように虚部が 0.0 と
-0.0 では値が変わります。
//emlist[例][ruby]{
Complex(-1, 0).arg #=> 3.141592653589793
Complex(-1, -0).arg #=> 3.141592653589793
Complex(-1... -
Complex
# polar -> [Numeric , Numeric] (24004.0) -
自身の絶対値と偏角を配列にして返します。
自身の絶対値と偏角を配列にして返します。
//emlist[例][ruby]{
Complex.polar(1, 2).polar # => [1, 2]
//}
@see Numeric#polar -
Complex
# quo(other) -> Complex (24004.0) -
商を計算します。
商を計算します。
@param other 自身を割る数
//emlist[例][ruby]{
Complex(10.0) / 3 # => (3.3333333333333335+(0/1)*i)
Complex(10) / 3 # => ((10/3)+(0/1)*i)
//}
@see Numeric#quo -
Complex
# rationalize -> Rational (24004.0) -
自身を Rational に変換します。
自身を Rational に変換します。
@param eps 許容する誤差。常に無視されます。
@raise RangeError 虚部が実数か、0 ではない場合に発生します。
//emlist[例][ruby]{
Complex(3).to_r # => (3/1)
Complex(3, 2).to_r # => RangeError
//} -
Complex
# rationalize(eps) -> Rational (24004.0) -
自身を Rational に変換します。
自身を Rational に変換します。
@param eps 許容する誤差。常に無視されます。
@raise RangeError 虚部が実数か、0 ではない場合に発生します。
//emlist[例][ruby]{
Complex(3).to_r # => (3/1)
Complex(3, 2).to_r # => RangeError
//} -
Complex
# real -> Numeric (24004.0) -
自身の実部を返します。
自身の実部を返します。
//emlist[例][ruby]{
Complex(3, 2).real # => 3
//} -
Complex
# real? -> false (24004.0) -
常に false を返します。
常に false を返します。
//emlist[例][ruby]{
(2+3i).real? # => false
(2+0i).real? # => false
//}
@see Numeric#real? -
Complex
# rect -> [Numeric , Numeric] (24004.0) -
実部と虚部を配列にして返します。
実部と虚部を配列にして返します。
//emlist[例][ruby]{
Complex(3).rect # => [3, 0]
Complex(3.5).rect # => [3.5, 0]
Complex(3, 2).rect # => [3, 2]
//}
@see Numeric#rect -
Complex
# rectangular -> [Numeric , Numeric] (24004.0) -
実部と虚部を配列にして返します。
実部と虚部を配列にして返します。
//emlist[例][ruby]{
Complex(3).rect # => [3, 0]
Complex(3.5).rect # => [3.5, 0]
Complex(3, 2).rect # => [3, 2]
//}
@see Numeric#rect -
Complex
# to _ c -> self (24004.0) -
self を返します。
self を返します。
//emlist[例][ruby]{
Complex(2).to_c # => (2+0i)
Complex(-8, 6).to_c # => (-8+6i)
//} -
Complex
# to _ f -> Float (24004.0) -
自身を Float に変換します。
自身を Float に変換します。
@raise RangeError 虚部が実数か、0 ではない場合に発生します。
//emlist[例][ruby]{
Complex(3).to_f # => 3.0
Complex(3.5).to_f # => 3.5
Complex(3, 2).to_f # => RangeError
//} -
Complex
# to _ i -> Integer (24004.0) -
自身を整数に変換します。
自身を整数に変換します。
@raise RangeError 虚部が実数か、0 ではない場合に発生します。
//emlist[例][ruby]{
Complex(3).to_i # => 3
Complex(3.5).to_i # => 3
Complex(3, 2).to_i # => RangeError
//} -
Complex
# to _ r -> Rational (24004.0) -
自身を Rational に変換します。
自身を Rational に変換します。
@param eps 許容する誤差。常に無視されます。
@raise RangeError 虚部が実数か、0 ではない場合に発生します。
//emlist[例][ruby]{
Complex(3).to_r # => (3/1)
Complex(3, 2).to_r # => RangeError
//} -
Complex
# to _ s -> String (24004.0) -
自身を "実部 + 虚部i" 形式の文字列にして返します。
自身を "実部 + 虚部i" 形式の文字列にして返します。
//emlist[例][ruby]{
Complex(2).to_s # => "2+0i"
Complex('-8/6').to_s # => "-4/3+0i"
Complex('1/2i').to_s # => "0+1/2i"
Complex(0, Float::INFINITY).to_s # => "0+Infinity*i"
Complex(Float::NAN, Float::NAN).to_s... -
Dir
# close -> nil (24004.0) -
ディレクトリストリームをクローズします。 以降のディレクトリに対する操作は例外 IOError を発生させます。 クローズに成功すれば nil を返します。
ディレクトリストリームをクローズします。
以降のディレクトリに対する操作は例外 IOError を発生させます。
クローズに成功すれば nil を返します。
//emlist[例][ruby]{
d = Dir.new(".")
d.close # => nil
//}
@raise IOError close に失敗した場合に発生します。また既に自身が close している場合に発生します。 -
Dir
# each -> Enumerator (24004.0) -
ディレクトリの各エントリを表す文字列を引数として、ブロックを評価します。
ディレクトリの各エントリを表す文字列を引数として、ブロックを評価します。
ブロックが与えられなかった場合、各エントリを文字列として保持する
Enumerator
オブジェクトを返します。
@raise IOError 既に自身が close している場合に発生します。
//emlist[例][ruby]{
Dir.open('.').each{|f|
p f
}
#=> "."
# ".."
# "bar"
# "foo"
//} -
Dir
# each {|item| . . . } -> self (24004.0) -
ディレクトリの各エントリを表す文字列を引数として、ブロックを評価します。
ディレクトリの各エントリを表す文字列を引数として、ブロックを評価します。
ブロックが与えられなかった場合、各エントリを文字列として保持する
Enumerator
オブジェクトを返します。
@raise IOError 既に自身が close している場合に発生します。
//emlist[例][ruby]{
Dir.open('.').each{|f|
p f
}
#=> "."
# ".."
# "bar"
# "foo"
//} -
Dir
# fileno -> Integer (24004.0) -
self に関連づけられたファイル記述子を表す整数を返します。
self に関連づけられたファイル記述子を表す整数を返します。
//emlist[例][ruby]{
Dir.open("..") { |d| d.fileno } # => 8
//}
本メソッドでは POSIX 2008 で定義されている dirfd() 関数を使用します。
@raise NotImplementedError Windows などの dirfd() 関数が存在しないプラッ
トフォームで発生します。
@raise IOError 既に自身が close している場合に発生します。
@see IO#fileno -
Dir
# inspect -> String (24004.0) -
self の情報を人間に読みやすい文字列にして返します。
self の情報を人間に読みやすい文字列にして返します。
//emlist[例][ruby]{
Dir.open("/") { |d| d.inspect } # => "#<Dir:/>"
//} -
Dir
# path -> String (24004.0) -
オープンしているディレクトリのパス名を文字列で返します。
オープンしているディレクトリのパス名を文字列で返します。
//emlist[例][ruby]{
Dir.open("..") do |d|
d.path # => ".."
d.to_path # => ".."
end
//} -
Dir
# pos -> Integer (24004.0) -
ディレクトリストリームの現在の位置を整数で返します。
ディレクトリストリームの現在の位置を整数で返します。
@raise IOError 既に自身が close している場合に発生します。
//emlist[例][ruby]{
Dir.open("/tmp") {|d|
d.each {|f|
p d.pos
}
}
//} -
Dir
# pos=(pos) (24004.0) -
ディレクトリストリームの読み込み位置を pos に移動させます。 pos は Dir#tell で与えられた値でなければなりま せん。
ディレクトリストリームの読み込み位置を pos に移動させます。
pos は Dir#tell で与えられた値でなければなりま
せん。
@param pos 変更したい位置を整数で与えます。
@raise IOError 既に自身が close している場合に発生します。
//emlist[例][ruby]{
Dir.open("testdir") do |d|
d.read # => "."
i = d.tell # => 12
d.read # => ".."
d.s... -
Dir
# read -> String | nil (24004.0) -
ディレクトリストリームから次の要素を読み出して返します。最後の要素 まで読み出していれば nil を返します。
ディレクトリストリームから次の要素を読み出して返します。最後の要素
まで読み出していれば nil を返します。
@raise Errno::EXXX ディレクトリの読み出しに失敗した場合に発生します。
@raise IOError 既に自身が close している場合に発生します。
//emlist[例][ruby]{
require 'tmpdir'
Dir.mktmpdir do |tmpdir|
File.open("#{tmpdir}/test1.txt", "w") { |f| f.puts("test1") }
File.open("#{tmpdir}/test2... -
Dir
# rewind -> self (24004.0) -
ディレクトリストリームの読み込み位置を先頭に移動させます。
ディレクトリストリームの読み込み位置を先頭に移動させます。
@raise IOError 既に自身が close している場合に発生します。
//emlist[例][ruby]{
Dir.open("testdir") do |d|
d.read # => "."
d.rewind # => #<Dir:0x401b3fb0>
d.read # => "."
end
//} -
Dir
# seek(pos) -> self (24004.0) -
ディレクトリストリームの読み込み位置を pos に移動させます。 pos は Dir#tell で与えられた値でなければなりま せん。
ディレクトリストリームの読み込み位置を pos に移動させます。
pos は Dir#tell で与えられた値でなければなりま
せん。
@param pos 変更したい位置を整数で与えます。
@raise IOError 既に自身が close している場合に発生します。
//emlist[例][ruby]{
Dir.open("testdir") do |d|
d.read # => "."
i = d.tell # => 12
d.read # => ".."
d.s... -
Dir
# tell -> Integer (24004.0) -
ディレクトリストリームの現在の位置を整数で返します。
ディレクトリストリームの現在の位置を整数で返します。
@raise IOError 既に自身が close している場合に発生します。
//emlist[例][ruby]{
Dir.open("/tmp") {|d|
d.each {|f|
p d.pos
}
}
//} -
Dir
# to _ path -> String (24004.0) -
オープンしているディレクトリのパス名を文字列で返します。
オープンしているディレクトリのパス名を文字列で返します。
//emlist[例][ruby]{
Dir.open("..") do |d|
d.path # => ".."
d.to_path # => ".."
end
//} -
Encoding
# ascii _ compatible? -> bool (24004.0) -
自身が ASCII 互換のエンコーディングである場合真返します。 そうでない場合は偽を返します。
自身が ASCII 互換のエンコーディングである場合真返します。
そうでない場合は偽を返します。
//emlist[例][ruby]{
Encoding::UTF_8.ascii_compatible? #=> true
Encoding::UTF_16BE.ascii_compatible? #=> false
//} -
Encoding
# dummy? -> bool (24004.0) -
自身がダミーエンコーディングである場合に true を返します。 そうでない場合に false を返します。
自身がダミーエンコーディングである場合に true を返します。
そうでない場合に false を返します。
ダミーエンコーディングとは Ruby が名前を知っているものの実質的には対応していないエンコーディングのことです。例えば、ダミーエンコーディングで符号化された文字列の場合、 String#length はマルチバイト文字を考慮せずにバイト列の長さを返します。
ダミーエンコーディングも IO の外部エンコーディングに指定できます。また
Ruby はサポートしていないが拡張ライブラリがサポートしているエンコーディングを扱う場合にも
用います。
//emlist[例][ruby]{
E... -
Encoding
# inspect -> String (24004.0) -
プログラマにわかりやすい表現の文字列を返します。
プログラマにわかりやすい表現の文字列を返します。
//emlist[例][ruby]{
Encoding::UTF_8.inspect #=> "#<Encoding:UTF-8>"
Encoding::ISO_2022_JP.inspect #=> "#<Encoding:ISO-2022-JP (dummy)>"
//} -
Encoding
# name -> String (24004.0) -
エンコーディングの名前を返します。
エンコーディングの名前を返します。
//emlist[例][ruby]{
Encoding::UTF_8.name #=> "UTF-8"
//} -
Encoding
# names -> String (24004.0) -
エンコーディングの名前とエイリアス名の配列を返します。
エンコーディングの名前とエイリアス名の配列を返します。
//emlist[例][ruby]{
Encoding::UTF_8.names #=> ["UTF-8", "CP65001"]
//} -
Encoding
# replicate(name) -> Encoding (24004.0) -
レシーバのエンコーディングを複製(replicate)します。 複製されたエンコーディングは元のエンコーディングと同じバイト構造を持たなければなりません。 name という名前のエンコーディングが既に存在する場合は ArgumentError を発生します。
レシーバのエンコーディングを複製(replicate)します。
複製されたエンコーディングは元のエンコーディングと同じバイト構造を持たなければなりません。
name という名前のエンコーディングが既に存在する場合は ArgumentError を発生します。
Ruby 3.2 から非推奨となり、Ruby 3.3 で削除予定です。
//emlist[][ruby]{
encoding = Encoding::UTF_8.replicate("REPLICATED_UTF-8") #=> #<Encoding:REPLICATED_UTF-8>
encoding.name ... -
Encoding
# to _ s -> String (24004.0) -
エンコーディングの名前を返します。
エンコーディングの名前を返します。
//emlist[例][ruby]{
Encoding::UTF_8.name #=> "UTF-8"
//} -
Encoding
:: Converter # convert(source _ string) -> String (24004.0) -
与えられた文字列を変換して、変換できた結果を返します。 引数の末尾の文字がバイト列の途中で終わっている場合、そのバイト列は変換器内に取り置かれます。 変換を終了させるには Encoding::Converter#finish を呼びます。
与えられた文字列を変換して、変換できた結果を返します。
引数の末尾の文字がバイト列の途中で終わっている場合、そのバイト列は変換器内に取り置かれます。
変換を終了させるには Encoding::Converter#finish を呼びます。
Encoding::Converter を用いると、文字列の一部または全部を渡して変換を行うことができます。よって、不正なバイトを意識せずにストリームから読み出した文字列を変換したいときには Encoding::Converter が適します。
なお、Encoding::Converter#convert では、これらの例外を捕獲しても、例外を起こしたと... -
Encoding
:: Converter # convpath -> Array (24004.0) -
変換器が行う変換の経路を配列にして返します。
変換器が行う変換の経路を配列にして返します。
@return 変換器が行う変換の経路の配列
//emlist[][ruby]{
ec = Encoding::Converter.new("ISo-8859-1", "EUC-JP", crlf_newline: true)
p ec.convpath
#=> [[#<Encoding:ISO-8859-1>, #<Encoding:UTF-8>],
# [#<Encoding:UTF-8>, #<Encoding:EUC-JP>],
# "crlf_newline"]
//}
@see Encoding::Converter.... -
Encoding
:: Converter # destination _ encoding -> Encoding (24004.0) -
変換先のエンコーディングを返します。
変換先のエンコーディングを返します。
@return 変換先のエンコーディング
//emlist[][ruby]{
ec = Encoding::Converter.new("utf-8", "euc-jp")
ec.destination_encoding #=> #<Encoding:EUC-JP>
//} -
Encoding
:: Converter # finish -> String (24004.0) -
変換処理を終了し、結果文字列の末尾を返します。 変換元の文字列の末尾がバイト列の途中で終わっていた場合、保持しているバイト列全てを返します。
変換処理を終了し、結果文字列の末尾を返します。
変換元の文字列の末尾がバイト列の途中で終わっていた場合、保持しているバイト列全てを返します。
@return 変換結果の末尾
@raise Encoding::InvalidByteSequenceError 変換元のエンコーディングにお
いて不正なバイト列があった場合に発生します。
//emlist[][ruby]{
ec = Encoding::Converter.new("utf-8", "iso-2022-jp")
p ec.convert("\u3042") #=> "\e$B$\""
p ec.finish ... -
Encoding
:: Converter # insert _ output(string) -> nil (24004.0) -
変換器内のバッファに文字列を挿入します。 バッファに保持された文字列は、次の変換時の変換結果と一緒に返されます。
変換器内のバッファに文字列を挿入します。
バッファに保持された文字列は、次の変換時の変換結果と一緒に返されます。
変換先がステートフルなエンコーディングであった場合、
挿入された文字列は状態に基づいて変換され、状態を更新します。
このメソッドは変換に際してエラーが発生した際にのみ利用されるべきです。
@param string 挿入する文字列
//emlist[][ruby]{
ec = Encoding::Converter.new("utf-8", "iso-8859-1")
src = "HIRAGANA LETTER A is \u{3042}."
dst = ""
p ec.... -
Encoding
:: Converter # inspect -> String (24004.0) -
Encoding::Converter オブジェクトの情報を簡単に表示します。
Encoding::Converter オブジェクトの情報を簡単に表示します。
@return 変換器の情報を簡単に可視化した文字列です。 -
Encoding
:: Converter # last _ error -> Exception | nil (24004.0) -
直前に変換器で発生した例外に相当する例外オブジェクトを返します。 直前の変換で例外が発生していない場合は nil を返します。
直前に変換器で発生した例外に相当する例外オブジェクトを返します。
直前の変換で例外が発生していない場合は nil を返します。
//emlist[][ruby]{
ec = Encoding::Converter.new("utf-8", "iso-8859-1")
p ec.primitive_convert(src="\xf1abcd", dst="") #=> :invalid_byte_sequence
p ec.last_error #=> #<Encoding::InvalidByteSequenceError: "\xF1" followed by "a"... -
Encoding
:: Converter # primitive _ convert(source _ buffer , destination _ buffer) -> Symbol (24004.0) -
エンコーディング変換のためのメソッドの中で、もっとも細かな扱いが可能なメソッドです。
エンコーディング変換のためのメソッドの中で、もっとも細かな扱いが可能なメソッドです。
可搬性を確保しつつ、不正なバイトや変換先で未定義な文字の扱いを細かに指定したいときは、Encoding::Converter#primitive_convert が唯一の方法になります。
@param source_buffer 変換元文字列のバッファ
@param destination_buffer 変換先文字列を格納するバッファ
@param destination_byteoffset 変換先バッファでのオフセット
@param destination_bytesize 変換先バッファの容量
@... -
Encoding
:: Converter # primitive _ convert(source _ buffer , destination _ buffer , destination _ byteoffset) -> Symbol (24004.0) -
エンコーディング変換のためのメソッドの中で、もっとも細かな扱いが可能なメソッドです。
エンコーディング変換のためのメソッドの中で、もっとも細かな扱いが可能なメソッドです。
可搬性を確保しつつ、不正なバイトや変換先で未定義な文字の扱いを細かに指定したいときは、Encoding::Converter#primitive_convert が唯一の方法になります。
@param source_buffer 変換元文字列のバッファ
@param destination_buffer 変換先文字列を格納するバッファ
@param destination_byteoffset 変換先バッファでのオフセット
@param destination_bytesize 変換先バッファの容量
@... -
Encoding
:: Converter # primitive _ convert(source _ buffer , destination _ buffer , destination _ byteoffset , destination _ bytesize) -> Symbol (24004.0) -
エンコーディング変換のためのメソッドの中で、もっとも細かな扱いが可能なメソッドです。
エンコーディング変換のためのメソッドの中で、もっとも細かな扱いが可能なメソッドです。
可搬性を確保しつつ、不正なバイトや変換先で未定義な文字の扱いを細かに指定したいときは、Encoding::Converter#primitive_convert が唯一の方法になります。
@param source_buffer 変換元文字列のバッファ
@param destination_buffer 変換先文字列を格納するバッファ
@param destination_byteoffset 変換先バッファでのオフセット
@param destination_bytesize 変換先バッファの容量
@... -
Encoding
:: Converter # primitive _ convert(source _ buffer , destination _ buffer , destination _ byteoffset , destination _ bytesize , options) -> Symbol (24004.0) -
エンコーディング変換のためのメソッドの中で、もっとも細かな扱いが可能なメソッドです。
エンコーディング変換のためのメソッドの中で、もっとも細かな扱いが可能なメソッドです。
可搬性を確保しつつ、不正なバイトや変換先で未定義な文字の扱いを細かに指定したいときは、Encoding::Converter#primitive_convert が唯一の方法になります。
@param source_buffer 変換元文字列のバッファ
@param destination_buffer 変換先文字列を格納するバッファ
@param destination_byteoffset 変換先バッファでのオフセット
@param destination_bytesize 変換先バッファの容量
@... -
Encoding
:: Converter # primitive _ errinfo -> Array (24004.0) -
直前の Encoding::Converter#primitive_convert による変換の結果を保持する五要素の配列を返します。
直前の Encoding::Converter#primitive_convert による変換の結果を保持する五要素の配列を返します。
@return [result, enc1, enc2, error_bytes, readagain_bytes] という五要素の配列
result は直前の primitive_convert の戻り値です。
それ以外の四要素は :invalid_byte_sequence か :incomplete_input か :undefined_conversion だった場合に意味を持ちます。
enc1 はエラーの発生した原始変換の変換元のエンコーディング... -
Encoding
:: Converter # putback -> String (24004.0) -
後の変換用に変換器内部で保持しているバイト列を max_numbytes で指定した バイト数だけ返します。max_numbytes を指定しなかった場合は保持しているバ イト列の全てを返します。
後の変換用に変換器内部で保持しているバイト列を max_numbytes で指定した
バイト数だけ返します。max_numbytes を指定しなかった場合は保持しているバ
イト列の全てを返します。
@param max_numbytes 取得するバイト列の最大値
@return 格納されていたバイト列
//emlist[][ruby]{
ec = Encoding::Converter.new("utf-16le", "iso-8859-1")
src = "\x00\xd8\x61\x00"
dst = ""
p ec.primitive_convert(src, dst) #=>... -
Encoding
:: Converter # putback(max _ numbytes) -> String (24004.0) -
後の変換用に変換器内部で保持しているバイト列を max_numbytes で指定した バイト数だけ返します。max_numbytes を指定しなかった場合は保持しているバ イト列の全てを返します。
後の変換用に変換器内部で保持しているバイト列を max_numbytes で指定した
バイト数だけ返します。max_numbytes を指定しなかった場合は保持しているバ
イト列の全てを返します。
@param max_numbytes 取得するバイト列の最大値
@return 格納されていたバイト列
//emlist[][ruby]{
ec = Encoding::Converter.new("utf-16le", "iso-8859-1")
src = "\x00\xd8\x61\x00"
dst = ""
p ec.primitive_convert(src, dst) #=>... -
Encoding
:: Converter # replacement -> String (24004.0) -
変換器に設定されている置換文字を返します。
変換器に設定されている置換文字を返します。
@return 変換器に設定されている置換文字
//emlist[][ruby]{
ec = Encoding::Converter.new("euc-jp", "us-ascii")
p ec.replacement #=> "?"
ec = Encoding::Converter.new("euc-jp", "utf-8")
p ec.replacement #=> "\uFFFD"
//} -
Encoding
:: Converter # replacement=(string) (24004.0) -
置換文字を設定します。
置換文字を設定します。
@param string 変換器に設定する置換文字
//emlist[][ruby]{
ec = Encoding::Converter.new("utf-8", "us-ascii", :undef => :replace)
ec.replacement = "<undef>"
p ec.convert("a \u3042 b") #=> "a <undef> b"
//} -
Encoding
:: Converter # source _ encoding -> Encoding (24004.0) -
変換元のエンコーディングを返します。
変換元のエンコーディングを返します。
@return 変換元のエンコーディング
//emlist[][ruby]{
ec = Encoding::Converter.new("utf-8", "euc-jp")
ec.source_encoding #=> #<Encoding:UTF-8>
//} -
Encoding
:: InvalidByteSequenceError # destination _ encoding -> Encoding (24004.0) -
エラーを発生させた変換の変換先のエンコーディングを Encoding オブジェクトで返します。
エラーを発生させた変換の変換先のエンコーディングを Encoding
オブジェクトで返します。
@see Encoding::InvalidByteSequenceError#source_encoding,
Encoding::UndefinedConversionError#destination_encoding -
Encoding
:: InvalidByteSequenceError # destination _ encoding _ name -> String (24004.0) -
エラーを発生させた変換の変換先のエンコーディングを文字列で返します。
エラーを発生させた変換の変換先のエンコーディングを文字列で返します。
@see Encoding::InvalidByteSequenceError#destination_encoding -
Encoding
:: InvalidByteSequenceError # error _ bytes -> String (24004.0) -
エラー発生時に捨てられたバイト列を返します。
エラー発生時に捨てられたバイト列を返します。
//emlist[例][ruby]{
ec = Encoding::Converter.new("EUC-JP", "ISO-8859-1")
begin
ec.convert("abc\xA1\xFFdef")
rescue Encoding::InvalidByteSequenceError
p $!
#=> #<Encoding::InvalidByteSequenceError: "\xA1" followed by "\xFF" on EUC-JP>
puts $!.error_bytes.dump ... -
Encoding
:: InvalidByteSequenceError # incomplete _ input? -> bool (24004.0) -
エラー発生時に入力文字列が不足している場合に真を返します。
エラー発生時に入力文字列が不足している場合に真を返します。
つまり、マルチバイト文字列の途中で文字列が終わっている場合に
真を返します。これは後続の入力を追加することでエラーが
解消する可能性があることを意味します。
//emlist[例][ruby]{
ec = Encoding::Converter.new("EUC-JP", "ISO-8859-1")
begin
ec.convert("abc\xA1z")
rescue Encoding::InvalidByteSequenceError
p $!
#=> #<Encoding::InvalidByteSequenc... -
Encoding
:: InvalidByteSequenceError # readagain _ bytes -> String (24004.0) -
エラー発生時に読み直さなければならないバイト列を返します。
エラー発生時に読み直さなければならないバイト列を返します。
@see Encoding::InvalidByteSequenceError#error_bytes -
Encoding
:: InvalidByteSequenceError # source _ encoding -> Encoding (24004.0) -
エラーを発生させた変換の変換元のエンコーディングを Encoding オブジェクトで返します。
エラーを発生させた変換の変換元のエンコーディングを Encoding
オブジェクトで返します。
@see Encoding::InvalidByteSequenceError#destination_encoding,
Encoding::UndefinedConversionError#source_encoding -
Encoding
:: InvalidByteSequenceError # source _ encoding _ name -> Encoding (24004.0) -
エラーを発生させた変換の変換元のエンコーディングを文字列で返します。
エラーを発生させた変換の変換元のエンコーディングを文字列で返します。
@see Encoding::InvalidByteSequenceError#source_encoding -
Encoding
:: UndefinedConversionError # destination _ encoding -> Encoding (24004.0) -
エラーを発生させた変換の変換先のエンコーディングを Encoding オブジェクトで返します。
エラーを発生させた変換の変換先のエンコーディングを Encoding
オブジェクトで返します。
@see Encoding::UndefinedConversionError#source_encoding -
Encoding
:: UndefinedConversionError # destination _ encoding _ name -> String (24004.0) -
エラーを発生させた変換の変換先のエンコーディングを文字列で返します。
エラーを発生させた変換の変換先のエンコーディングを文字列で返します。
@see Encoding::UndefinedConversionError#destination_encoding -
Encoding
:: UndefinedConversionError # error _ char -> String (24004.0) -
エラーを発生させた1文字を文字列で返します。
エラーを発生させた1文字を文字列で返します。
//emlist[例][ruby]{
ec = Encoding::Converter.new("UTF-8", "EUC-JP")
begin
ec.convert("\u{a0}")
rescue Encoding::UndefinedConversionError
puts $!.error_char.dump #=> "\u{a0}"
end
//} -
Encoding
:: UndefinedConversionError # source _ encoding -> Encoding (24004.0) -
エラーを発生させた変換の変換元のエンコーディングを Encoding オブジェクトで返します。
エラーを発生させた変換の変換元のエンコーディングを Encoding
オブジェクトで返します。
変換が多段階になされる場合は元の文字列のものではない
エンコーディングが返される場合があることに注意してください。
@see Encoding::UndefinedConversionError#destination_encoding -
Encoding
:: UndefinedConversionError # source _ encoding _ name -> Encoding (24004.0) -
エラーを発生させた変換の変換元のエンコーディングを文字列で返します。
エラーを発生させた変換の変換元のエンコーディングを文字列で返します。
@see Encoding::UndefinedConversionError#source_encoding -
Enumerable
# all? -> bool (24004.0) -
すべての要素が真である場合に true を返します。 偽である要素があれば、ただちに false を返します。
すべての要素が真である場合に true を返します。
偽である要素があれば、ただちに false を返します。
ブロックを伴う場合は、各要素に対してブロックを評価し、すべての結果
が真である場合に true を返します。ブロックが偽を返した時点で、
ただちに false を返します。
自身に要素が存在しない場合は true を返します。
//emlist[例][ruby]{
require 'set'
# すべて正の数か?
p Set[5, 6, 7].all? {|v| v > 0 } # => true
p Set[5, -1, 7].all? {|v| v > 0... -
Enumerable
# all? {|item| . . . } -> bool (24004.0) -
すべての要素が真である場合に true を返します。 偽である要素があれば、ただちに false を返します。
すべての要素が真である場合に true を返します。
偽である要素があれば、ただちに false を返します。
ブロックを伴う場合は、各要素に対してブロックを評価し、すべての結果
が真である場合に true を返します。ブロックが偽を返した時点で、
ただちに false を返します。
自身に要素が存在しない場合は true を返します。
//emlist[例][ruby]{
require 'set'
# すべて正の数か?
p Set[5, 6, 7].all? {|v| v > 0 } # => true
p Set[5, -1, 7].all? {|v| v > 0... -
Enumerable
# any? -> bool (24004.0) -
すべての要素が偽である場合に false を返します。 真である要素があれば、ただちに true を返します。
すべての要素が偽である場合に false を返します。
真である要素があれば、ただちに true を返します。
ブロックを伴う場合は、各要素に対してブロックを評価し、すべての結果
が偽である場合に false を返します。ブロックが真を返した時点
で、ただちに true を返します。
自身に要素が存在しない場合は false を返します。
//emlist[例][ruby]{
require 'set'
p Set[1, 2, 3].any? {|v| v > 3 } # => false
p Set[1, 2, 3].any? {|v| v > 1 } ... -
Enumerable
# any? {|item| . . . } -> bool (24004.0) -
すべての要素が偽である場合に false を返します。 真である要素があれば、ただちに true を返します。
すべての要素が偽である場合に false を返します。
真である要素があれば、ただちに true を返します。
ブロックを伴う場合は、各要素に対してブロックを評価し、すべての結果
が偽である場合に false を返します。ブロックが真を返した時点
で、ただちに true を返します。
自身に要素が存在しない場合は false を返します。
//emlist[例][ruby]{
require 'set'
p Set[1, 2, 3].any? {|v| v > 3 } # => false
p Set[1, 2, 3].any? {|v| v > 1 } ... -
Enumerable
# chunk {|elt| . . . } -> Enumerator (24004.0) -
要素を前から順にブロックで評価し、その結果によって 要素をチャンクに分けた(グループ化した)要素を持つ Enumerator を返します。
要素を前から順にブロックで評価し、その結果によって
要素をチャンクに分けた(グループ化した)要素を持つ
Enumerator を返します。
ブロックの評価値が同じ値が続くものを一つのチャンクとして
取り扱います。すなわち、ブロックの評価値が一つ前と
異なる所でチャンクが区切られます。
返り値の Enumerator は各チャンクのブロック評価値と
各チャンクの要素を持つ配列のペアを各要素とします。
そのため、eachだと以下のようになります。
//emlist[][ruby]{
enum.chunk {|elt| key }.each {|key, ary| do_something ... -
Enumerable
# chunk _ while {|elt _ before , elt _ after| . . . } -> Enumerator (24004.0) -
要素を前から順にブロックで評価し、その結果によって要素をチャンクに分け た(グループ化した)要素を持つEnumerator を返します。
要素を前から順にブロックで評価し、その結果によって要素をチャンクに分け
た(グループ化した)要素を持つEnumerator を返します。
隣り合う値をブロックパラメータ elt_before、elt_after に渡し、ブロックの
評価値が偽になる所でチャンクを区切ります。
ブロックは self の長さ - 1 回呼び出されます。
@return チャンクごとの配列をブロックパラメータに渡す Enumerator
を返します。eachメソッドは以下のように呼び出します。
//emlist{
enum.chunk_while { |elt_before, elt_af... -
Enumerable
# collect -> Enumerator (24004.0) -
各要素に対してブロックを評価した結果を全て含む配列を返します。
各要素に対してブロックを評価した結果を全て含む配列を返します。
ブロックを省略した場合は Enumerator を返します。
//emlist[例][ruby]{
# すべて 3 倍にした配列を返す
p (1..3).map {|n| n * 3 } # => [3, 6, 9]
p (1..3).collect { "cat" } # => ["cat", "cat", "cat"]
//}
@see Array#collect, Array#map -
Enumerable
# collect {|item| . . . } -> [object] (24004.0) -
各要素に対してブロックを評価した結果を全て含む配列を返します。
各要素に対してブロックを評価した結果を全て含む配列を返します。
ブロックを省略した場合は Enumerator を返します。
//emlist[例][ruby]{
# すべて 3 倍にした配列を返す
p (1..3).map {|n| n * 3 } # => [3, 6, 9]
p (1..3).collect { "cat" } # => ["cat", "cat", "cat"]
//}
@see Array#collect, Array#map -
Enumerable
# collect _ concat -> Enumerator (24004.0) -
各要素をブロックに渡し、その返り値を連結した配列を返します。
各要素をブロックに渡し、その返り値を連結した配列を返します。
ブロックの返り値は基本的に配列を返すべきです。
ブロックを省略した場合は Enumerator を返します。
//emlist[例][ruby]{
[[1,2], [3,4]].flat_map{|i| i.map{|j| j*2}} # => [2,4,6,8]
//}