クラス
-
ARGF
. class (843) - Array (1382)
- BasicObject (99)
- Bignum (54)
- Binding (60)
- Class (58)
- Complex (483)
- Data (10)
- Dir (94)
- Encoding (33)
-
Encoding
:: Converter (88) -
Encoding
:: InvalidByteSequenceError (77) - Enumerator (66)
-
Enumerator
:: ArithmeticSequence (59) -
Enumerator
:: Chain (6) -
Enumerator
:: Lazy (378) -
Enumerator
:: Yielder (27) - Exception (62)
- FalseClass (55)
- Fiber (19)
- File (131)
-
File
:: Stat (462) - Fixnum (57)
- Float (475)
- Hash (824)
- IO (890)
- Integer (307)
- LoadError (11)
- LocalJumpError (22)
- MatchData (136)
- Method (121)
- Module (898)
- Mutex (12)
- NameError (20)
- NilClass (149)
- NoMethodError (8)
- Numeric (338)
- Object (550)
-
ObjectSpace
:: WeakMap (22) - Proc (69)
-
Process
:: Status (99) -
Process
:: Tms (44) - Random (77)
- Range (193)
- Rational (315)
- Refinement (3)
- Regexp (107)
-
RubyVM
:: AbstractSyntaxTree :: Node (36) -
RubyVM
:: InstructionSequence (75) - SignalException (22)
- StopIteration (11)
- String (1277)
- Struct (170)
- Symbol (371)
- SystemCallError (11)
- SystemExit (11)
- Thread (305)
-
Thread
:: Backtrace :: Location (77) -
Thread
:: ConditionVariable (27) -
Thread
:: Mutex (54) -
Thread
:: Queue (108) -
Thread
:: SizedQueue (75) - ThreadGroup (44)
- Time (274)
- TracePoint (140)
- TrueClass (55)
- UnboundMethod (97)
- UncaughtThrowError (10)
モジュール
- Comparable (79)
- Enumerable (1294)
- GC (11)
- Warning (8)
キーワード
- ! (11)
- != (11)
- !~ (11)
- % (17)
- & (33)
- * (39)
- ** (39)
- + (39)
- +@ (20)
- - (50)
- -@ (39)
-
/ (39) - < (67)
- << (65)
- <= (67)
- <=> (129)
- == (234)
- === (80)
- =~ (48)
- > (67)
- >= (67)
- >> (12)
- [] (192)
- []= (154)
- ^ (33)
-
_ dump (11) -
_ load (11) -
abort
_ on _ exception (11) - abs (30)
- abs2 (11)
-
absolute
_ path (22) - add (11)
- advise (11)
-
alias
_ method (11) - alive? (14)
- all? (47)
- allbits? (7)
- allocate (11)
- ancestors (11)
- angle (33)
- any? (56)
- anybits? (7)
- append (7)
-
append
_ features (11) - arg (33)
- argv (11)
-
ascii
_ compatible? (11) -
ascii
_ only? (11) - assoc (22)
- at (11)
- atime (22)
- attr (33)
-
attr
_ accessor (11) -
attr
_ reader (11) -
attr
_ writer (11) - autoclose= (11)
- autoclose? (11)
- autoload (11)
- autoload? (11)
- backtrace (11)
-
backtrace
_ locations (33) -
base
_ label (22) - begin (16)
- between? (22)
-
bind
_ call (10) - binding (2)
- binmode (22)
- binmode? (22)
- birthtime (21)
-
bit
_ length (17) - blksize (11)
- blockdev? (11)
- blocks (11)
- broadcast (9)
- bsearch (22)
-
bsearch
_ index (9) - byteindex (2)
- byteoffset (4)
- byterindex (2)
- bytes (32)
- byteslice (33)
- bytesplice (4)
- call (33)
-
callee
_ id (11) - capitalize (22)
- capitalize! (11)
- casecmp (22)
- casecmp? (16)
- casefold? (11)
- cause (11)
- ceil (49)
- ceildiv (2)
- chain (6)
- chardev? (11)
- chars (43)
- children (12)
- chmod (11)
- chomp! (11)
- chop! (11)
- chown (11)
- chunk (33)
-
chunk
_ while (19) - clamp (24)
- class (11)
-
class
_ eval (22) -
class
_ exec (11) -
class
_ variable _ defined? (11) -
class
_ variable _ get (11) -
class
_ variable _ set (11) -
class
_ variables (11) - clear (42)
- clone (66)
- close (51)
-
close
_ on _ exec= (11) -
close
_ on _ exec? (11) -
close
_ read (11) -
close
_ write (11) - closed? (31)
- codepoints (32)
- coerce (22)
- collect (55)
- collect! (22)
-
collect
_ concat (33) - combination (11)
- compact (6)
- compact! (19)
-
compare
_ by _ identity (11) -
compare
_ by _ identity? (11) - concat (38)
- conj (11)
- conjugate (11)
-
const
_ added (2) -
const
_ defined? (11) -
const
_ get (11) -
const
_ missing (11) -
const
_ set (11) -
const
_ source _ location (5) - constants (11)
- convert (11)
- coredump? (11)
- count (33)
- cover? (17)
- crypt (11)
- cstime (11)
- ctime (22)
- cutime (11)
- cycle (44)
-
deconstruct
_ keys (2) - dedup (2)
- default (22)
- default= (11)
-
default
_ proc (11) -
default
_ proc= (11) -
define
_ method (22) -
define
_ singleton _ method (22) -
defined
_ class (11) - delete (55)
- delete! (11)
-
delete
_ at (11) -
delete
_ if (44) -
delete
_ prefix (7) -
delete
_ prefix! (7) -
delete
_ suffix (7) -
delete
_ suffix! (7) - denominator (33)
-
deprecate
_ constant (9) - deq (18)
-
destination
_ encoding (11) -
destination
_ encoding _ name (11) - detect (22)
- dev (11)
-
dev
_ major (11) -
dev
_ minor (11) - dig (27)
- directory? (11)
- disable (22)
- disassemble (11)
- display (11)
- div (6)
- divmod (11)
- downcase (11)
- downcase! (11)
- downto (11)
- drop (22)
-
drop
_ while (55) - dst? (11)
- dummy? (11)
- dup (44)
- each (185)
-
each
_ byte (44) -
each
_ char (55) -
each
_ child (12) -
each
_ codepoint (44) -
each
_ cons (22) -
each
_ entry (22) -
each
_ grapheme _ cluster (14) -
each
_ index (11) -
each
_ key (11) -
each
_ line (132) -
each
_ pair (22) -
each
_ slice (22) -
each
_ value (22) -
each
_ with _ index (22) -
each
_ with _ object (22) - eager (5)
- empty? (60)
- enable (22)
- enabled? (11)
- enclose (11)
- enclosed? (11)
- encode! (22)
- encoding (11)
- end (17)
-
end
_ with? (16) - enq (18)
- entries (11)
-
enum
_ for (22) - eof (22)
- eof? (22)
- eql? (148)
- equal? (44)
- errno (11)
-
error
_ bytes (11) - eval (22)
-
eval
_ script (6) - even? (17)
- event (11)
- exception (11)
-
exclude
_ end? (17) - executable? (11)
-
executable
_ real? (11) - exit (11)
-
exit
_ value (11) - exited? (11)
- exitstatus (11)
- extend (11)
-
extend
_ object (11) - extended (11)
-
external
_ encoding (22) - fcntl (11)
- fdiv (39)
- feed (11)
- fetch (18)
-
fetch
_ values (18) - file (11)
- file? (11)
- filename (11)
- fileno (32)
- fill (66)
- filter (54)
- filter! (24)
-
filter
_ map (15) - find (22)
-
find
_ all (33) -
find
_ index (55) - finite? (27)
- first (39)
-
first
_ column (6) -
first
_ lineno (17) -
fixed
_ encoding? (11) -
flat
_ map (33) - flatten (22)
- flatten! (11)
- flock (11)
- floor (49)
- flush (11)
- force (11)
-
force
_ encoding (11) - freeze (22)
- friday? (11)
- frozen? (11)
- ftype (11)
-
garbage
_ collect (11) - gcdlcm (11)
- getbyte (33)
- getc (22)
- getlocal (22)
- gets (66)
- gid (11)
- gmt? (11)
- gmtime (11)
-
grapheme
_ clusters (14) - grep (33)
-
grep
_ v (31) -
group
_ by (22) - grpowned? (11)
- gsub (11)
- gsub! (33)
-
has
_ key? (11) -
has
_ value? (11) - hash (22)
- i (11)
- id2name (11)
-
ignore
_ deadlock (4) -
ignore
_ deadlock= (4) - imag (11)
- imaginary (11)
-
import
_ methods (3) - include (11)
- include? (66)
- included (11)
-
included
_ modules (11) -
incomplete
_ input? (11) - index (40)
- infinite? (27)
- inherited (11)
- initialize (11)
-
initialize
_ copy (11) - inject (33)
- ino (11)
-
inplace
_ mode (11) -
inplace
_ mode= (11) - insert (22)
-
insert
_ output (11) - inspect (99)
-
instance
_ eval (22) -
instance
_ method (11) -
instance
_ methods (11) -
instance
_ of? (11) -
instance
_ variable _ defined? (11) -
instance
_ variable _ get (11) -
instance
_ variable _ set (11) -
instance
_ variables (11) - integer? (11)
- intern (22)
-
internal
_ encoding (22) - intersect? (3)
- ioctl (11)
-
is
_ a? (11) - isatty (11)
- isdst (11)
- itself (11)
- join (22)
-
keep
_ if (28) - key (11)
- key? (22)
- keys (11)
- kill (11)
-
kind
_ of? (11) - label (22)
- lambda? (11)
- last (56)
-
last
_ column (6) -
last
_ error (11) -
last
_ lineno (6) - lazy (22)
- lcm (11)
- left (11)
- length (82)
- lineno (44)
- lineno= (22)
- lines (106)
- list (11)
- ljust (11)
-
local
_ variable _ defined? (11) -
local
_ variable _ get (11) -
local
_ variable _ set (11) -
local
_ variables (19) - localtime (22)
- lock (11)
- locked? (11)
- lstat (11)
- lstrip (11)
- lstrip! (11)
- magnitude (30)
- map (55)
- map! (22)
-
marshal
_ dump (44) -
marshal
_ load (22) - match (55)
- match? (24)
- max (82)
-
max
_ by (44) - member? (33)
- members (13)
- merge (11)
- merge! (22)
-
method
_ added (11) -
method
_ defined? (11) -
method
_ id (11) -
method
_ removed (11) -
method
_ undefined (11) - methods (11)
- min (82)
-
min
_ by (44) - minmax (22)
-
minmax
_ by (22) - mode (11)
-
module
_ eval (22) -
module
_ exec (11) -
module
_ function (19) - modulo (39)
- monday? (11)
- mtime (22)
- name (48)
- nan? (11)
- negative? (26)
- new (11)
- next (11)
-
next
_ float (10) -
next
_ values (11) - nil? (22)
- nlink (11)
- nobits? (7)
- none? (47)
- nonzero? (11)
- numerator (33)
- odd? (17)
- offset (22)
- one? (47)
-
original
_ name (22) - owned? (22)
- owner (22)
- pack (19)
- parameters (2)
- partition (22)
- path (46)
-
peek
_ values (11) -
pending
_ interrupt? (11) - permutation (22)
- phase (33)
- pid (11)
- pipe? (11)
- polar (22)
- pop (29)
- pos (11)
- pos= (11)
- positive? (26)
- pow (11)
- pread (7)
- prepend (18)
-
prepend
_ features (11) - prepended (11)
-
prev
_ float (10) -
primitive
_ convert (44) - print (22)
- printf (22)
- priority= (11)
- private (23)
-
private
_ call? (8) -
private
_ class _ method (15) -
private
_ constant (11) -
private
_ instance _ methods (11) -
private
_ method _ defined? (11) -
private
_ methods (11) - product (22)
- protected (23)
-
protected
_ instance _ methods (11) -
protected
_ method _ defined? (11) -
protected
_ methods (11) - public (23)
-
public
_ class _ method (15) -
public
_ constant (11) -
public
_ instance _ method (11) -
public
_ instance _ methods (11) -
public
_ method (11) -
public
_ method _ defined? (11) -
public
_ methods (11) -
public
_ send (22) - push (29)
- putc (11)
- puts (22)
- quo (33)
- raise (5)
- rand (33)
- rassoc (22)
- rationalize (99)
- rdev (11)
-
rdev
_ major (11) -
rdev
_ minor (11) - read (33)
-
read
_ nonblock (22) - readable? (11)
-
readable
_ real? (11) -
readagain
_ bytes (11) - readbyte (11)
- readchar (11)
- readline (66)
- readlines (66)
- readpartial (22)
- real (22)
- real? (22)
- reason (11)
- rect (11)
- rectangular (22)
- reduce (33)
- refine (11)
- rehash (11)
- reject (44)
- reject! (44)
- remainder (3)
-
remove
_ class _ variable (11) -
remove
_ const (11) -
remove
_ instance _ variable (11) -
remove
_ method (11) - reopen (33)
-
repeated
_ combination (11) -
repeated
_ permutation (11) - replace (33)
- replacement (11)
- replacement= (11)
- replicate (11)
-
report
_ on _ exception (8) -
respond
_ to? (11) -
respond
_ to _ missing? (11) - result (11)
- resume (11)
-
return
_ value (11) - reverse! (22)
-
reverse
_ each (33) - rewind (33)
- rindex (33)
- rotate! (11)
- round (41)
- rstrip! (11)
-
ruby2
_ keywords (5) - run (11)
-
safe
_ level (7) - sample (44)
- saturday? (11)
- scan (11)
- scrub (11)
- scrub! (11)
- seek (22)
- select (99)
- select! (44)
- self (11)
-
set
_ backtrace (11) -
set
_ encoding (66) -
set
_ encoding _ by _ bom (5) -
set
_ trace _ func (11) - setgid? (11)
- setuid? (11)
- shift (40)
- shuffle (22)
- shuffle! (22)
- signal (9)
- signaled? (11)
- signm (11)
- signo (11)
-
singleton
_ class (11) -
singleton
_ class? (11) -
singleton
_ method (11) -
singleton
_ method _ added (11) -
singleton
_ method _ removed (11) -
singleton
_ method _ undefined (11) -
singleton
_ methods (11) - size (138)
- size? (11)
- skip (11)
- sleep (11)
- slice (161)
- slice! (99)
-
slice
_ after (42) -
slice
_ before (55) -
slice
_ when (21) - socket? (11)
- sort (22)
- sort! (22)
-
sort
_ by (22) -
sort
_ by! (11) -
source
_ encoding (11) -
source
_ encoding _ name (11) -
source
_ location (39) - split (17)
- squeeze! (11)
-
start
_ with? (16) - stat (11)
- status (11)
- step (95)
- sticky? (11)
- stime (11)
- stop? (11)
- stopped? (11)
- stopsig (11)
- store (11)
- strftime (11)
- strip! (11)
- sub (11)
- sub! (22)
- subclasses (3)
- subsec (11)
- succ (11)
- success? (22)
- sum (22)
- sunday? (11)
-
super
_ method (20) - superclass (11)
- swapcase (11)
- swapcase! (11)
- symlink? (11)
- sync (11)
- sysread (11)
- taint (9)
- tainted? (9)
- take (22)
-
take
_ while (66) - tally (8)
- tap (11)
- tell (33)
- terminate (11)
- termsig (11)
-
thread
_ variable? (11) -
thread
_ variable _ get (11) -
thread
_ variable _ set (11) - thursday? (11)
- times (11)
-
to
_ a (55) -
to
_ ary (11) -
to
_ binary (9) -
to
_ c (44) -
to
_ enum (22) -
to
_ f (83) -
to
_ h (59) -
to
_ hash (11) -
to
_ i (77) -
to
_ int (11) -
to
_ io (22) -
to
_ path (13) -
to
_ proc (27) -
to
_ r (77) -
to
_ s (110) -
to
_ sym (22) -
to
_ write _ io (11) - tr (11)
- tr! (11)
-
tr
_ s (11) -
tr
_ s! (11) -
transform
_ keys! (11) -
transform
_ values (16) -
transform
_ values! (16) - truncate (37)
- trust (9)
-
try
_ lock (11) - tty? (11)
- tuesday? (11)
- type (6)
- uid (11)
-
undef
_ method (11) - ungetbyte (11)
- ungetc (11)
-
unicode
_ normalize (10) -
unicode
_ normalize! (10) -
unicode
_ normalized? (10) - uniq (38)
- uniq! (22)
- unlock (11)
- unpack (11)
- unshift (11)
- untaint (9)
- untrust (9)
- untrusted? (9)
- upcase (11)
- upcase! (11)
- update (22)
- upto (11)
- using (11)
- utc (11)
- utc? (11)
- utime (11)
-
valid
_ encoding? (11) - value (21)
- value? (11)
- values (22)
-
values
_ at (44) - wait (9)
- wakeup (11)
- warn (8)
- wednesday? (11)
-
with
_ index (10) -
world
_ readable? (11) -
world
_ writable? (11) - writable? (11)
-
writable
_ real? (11) - write (11)
-
write
_ nonblock (11) - yield (22)
-
yield
_ self (14) - zero? (36)
- zip (66)
- | (33)
- ~ (11)
検索結果
先頭5件
-
Class
# subclasses -> [Class] (9203.0) -
自身が直接のスーパークラスになっている(特異クラスを除く)クラスの配列を返します。 返り値の配列の順序は未定義です。
...を除く)クラスの配列を返します。
返り値の配列の順序は未定義です。
//emlist[例][ruby]{
class A; end
class B < A; end
class C < B; end
class D < A; end
A.subclasses # => [D, B]
B.subclasses # => [C]
C.subclasses # => []
//}
@see Class#superclass... -
Class
# superclass -> Class | nil (9203.0) -
自身のスーパークラスを返します。
...ます。
//emlist[例][ruby]{
File.superclass #=> IO
IO.superclass #=> Object
class Foo; end
class Bar < Foo; end
Bar.superclass #=> Foo
Object.superclass #=> BasicObject
//}
ただし BasicObject.superclass は nil を返します。
//emlist[例][ruby]{
Bas......icObject.superclass #=> nil
//}......icObject.superclass #=> nil
//}
@see Class#subclasses... -
Enumerable
# drop _ while {|element| . . . } -> Array (9203.0) -
ブロックを評価して最初に偽となった要素の手前の要素まで捨て、 残りの要素を配列として返します。
...価して最初に偽となった要素の手前の要素まで捨て、
残りの要素を配列として返します。
ブロックを指定しなかった場合は、Enumerator を返します。
//emlist[例][ruby]{
a = [1, 2, 3, 4, 5, 0]
a.drop_while {|i| i < 3 } # => [3, 4, 5, 0]
//}... -
Enumerable
# take _ while {|element| . . . } -> Array (9203.0) -
Enumerable オブジェクトの要素を順に偽になるまでブロックで評価します。 最初に偽になった要素の手前の要素までを配列として返します。
...Enumerable オブジェクトの要素を順に偽になるまでブロックで評価します。
最初に偽になった要素の手前の要素までを配列として返します。
//emlist[例][ruby]{
e = [1, 2, 3, 4, 5, 0].each
e.take_while {|i| i < 3 } # => [1, 2]
//}
ブロックを......省略した場合は Enumerator を返します。
@see Array#take_while... -
Float
# floor(ndigits = 0) -> Integer | Float (9203.0) -
自身と等しいかより小さな整数のうち最大のものを返します。
...合、Float を返します。
小数点以下を、最大 n 桁にします。
負の整数を指定した場合、Integer を返します。
小数点位置から左に少なくとも n 個の 0 が並びます。
//emlist[例][ruby]{
1.2.floor #......2.0.floor # => 2
(-1.2).floor # => -2
(-2.0).floor # => -2
1.234567.floor(2) # => 1.23
1.234567.floor(3) # => 1.234
1.234567.floor(4) # => 1.2345
1.234567.floor(5) # => 1.23456
34567.89.floor(-5) # => 0
34567.89.floor(-4) # => 30000
34567.89.floor(-3) # => 34000
34567.89.floor(......-2) # => 34500
34567.89.floor(-1) # => 34560
34567.89.floor(0) # => 34567
34567.89.floor(1) # => 34567.8
34567.89.floor(2) # => 34567.89
34567.89.floor(3) # => 34567.89
//}
@see Numeric#ceil, Numeric#round, Float#truncate... -
Float
# next _ float -> Float (9203.0) -
浮動小数点数で表現可能な self の次の値を返します。
...表現可能な self の次の値を返します。
Float::MAX.next_float、Float::INFINITY.next_float は
Float::INFINITY を返します。Float::NAN.next_float は
Float::NAN を返します。
//emlist[例][ruby]{
p 0.01.next_float # => 0.010000000000000002
p 1.0.next_float # => 1.000000000......00002
p 100.0.next_float # => 100.00000000000001
p 0.01.next_float - 0.01 # => 1.734723475976807e-18
p 1.0.next_float - 1.0 # => 2.220446049250313e-16
p 100.0.next_float - 100.0 # => 1.4210854715202004e-14
f = 0.01; 20.times { printf "%-20a %s\n", f, f.to_s; f = f.next_float }
# => 0x1.47ae1......47ae147ae1489p-7 0.010000000000000024
# 0x1.47ae147ae148ap-7 0.010000000000000026
# 0x1.47ae147ae148bp-7 0.010000000000000028
# 0x1.47ae147ae148cp-7 0.01000000000000003
# 0x1.47ae147ae148dp-7 0.010000000000000031
# 0x1.47ae147ae148ep-7 0.010000000000000033
//}
@see Float#prev_float... -
Float
# prev _ float -> Float (9203.0) -
浮動小数点数で表現可能な self の前の値を返します。
...現可能な self の前の値を返します。
(-Float::MAX).prev_float と (-Float::INFINITY).prev_float
は -Float::INFINITY を返します。Float::NAN.prev_float は
Float::NAN を返します。
//emlist[例][ruby]{
p 0.01.prev_float # => 0.009999999999999998
p 1.0.prev_float # => 0.999......99999
p 100.0.prev_float # => 99.99999999999999
p 0.01 - 0.01.prev_float # => 1.734723475976807e-18
p 1.0 - 1.0.prev_float # => 1.1102230246251565e-16
p 100.0 - 100.0.prev_float # => 1.4210854715202004e-14
f = 0.01; 20.times { printf "%-20a %s\n", f, f.to_s; f = f.prev_float }
# => 0x1.47ae1......47ae147ae146dp-7 0.009999999999999976
# 0x1.47ae147ae146cp-7 0.009999999999999974
# 0x1.47ae147ae146bp-7 0.009999999999999972
# 0x1.47ae147ae146ap-7 0.00999999999999997
# 0x1.47ae147ae1469p-7 0.009999999999999969
# 0x1.47ae147ae1468p-7 0.009999999999999967
//}
@see Float#next_float... -
ARGF
. class # inplace _ mode -> String | nil (9103.0) -
c:ARGF#inplace で書き換えるファイルのバックアップに付加される拡 張子を返します。拡張子が設定されていない場合は空文字列を返します。イン プレースモードでない場合は nil を返します。
...nplace で書き換えるファイルのバックアップに付加される拡
張子を返します。拡張子が設定されていない場合は空文字列を返します。イン
プレースモードでない場合は nil を返します。
Ruby 起動時の -i オプション や ARGF.clas......s#inplace_mode= で設定します。
例:
# $ echo "test" > test.txt
# $ ruby -i.bak test.rb test.txt
# $ cat test.txt # => "TEST"
# $ cat test.txt.bak # => "test"
# test.rb
ARGF.inplace_mode # => ".bak"
ARGF.each_line {|e|print e.upcase} # => "TEST"
例:
# $ e......cho "test" > test.txt
# $ ruby test.rb test.txt
# $ cat test.txt # => "test"
# test.rb
ARGF.inplace_mode # => nil
ARGF.each_line {|e|print e.upcase} # => "TEST"
@see d:spec/rubycmd#cmd_option, ARGF.class#inplace_mode=... -
ARGF
. class # inplace _ mode=(ext) (9103.0) -
c:ARGF#inplace時にバックアップファイルに付加する拡張子を設定します。 ピリオドも含めて指定する必要があります。
...c:ARGF#inplace時にバックアップファイルに付加する拡張子を設定します。
ピリオドも含めて指定する必要があります。
バックアップを残さない場合は空文字列を指定します。
この機能は Windows では使用出来ません。
設定が......ile.txt
---- argf.rb ----
# 引数のファイル中の各行の最初の "foo" を "bar" で置き換える
ARGF.inplace_mode = '.bak'
ARGF.lines do |line|
print line.sub("foo","bar")
end
---- -i オプションを使う場合 ----
$ ruby -i.bak -p -e '$_.sub!("foo","bar")' fil......e.txt
---- -i オプションを使う場合その2 ----
$ ruby -i.bak -n -e 'print $_.sub("foo","bar")' file.txt
@see d:spec/rubycmd#cmd_option, ARGF.class#inplace_mode... -
Complex
# angle -> Float (9103.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, -0.0).arg #=> -3.141592653589793
Complex(0, 0.0).arg #=> 0.0
Complex(0, -0.0).arg #=> -0.0
Complex(-0.0, 0).arg #=> 3.141592653589793
Complex(-0.0, -0.0).arg... -
Enumerable
# chunk _ while {|elt _ before , elt _ after| . . . } -> Enumerator (9103.0) -
要素を前から順にブロックで評価し、その結果によって要素をチャンクに分け た(グループ化した)要素を持つEnumerator を返します。
...つEnumerator を返します。
隣り合う値をブロックパラメータ elt_before、elt_after に渡し、ブロックの
評価値が偽になる所でチャンクを区切ります。
ブロックは self の長さ - 1 回呼び出されます。
@return チャンクごとの配列を......ドは以下のように呼び出します。
//emlist{
enum.chunk_while { |elt_before, elt_after| bool }.each { |ary| ... }
//}
to_a や map などのその他の Enumerable モジュールのメソッ
ドも有用です。
//emlist[例][ruby]{
# 1ずつ増加する部分配列......ごとに分ける。
a = [1,2,4,9,10,11,12,15,16,19,20,21]
b = a.chunk_while {|i, j| i+1 == j }
p b.to_a # => [[1, 2], [4], [9, 10, 11, 12], [15, 16], [19, 20, 21]]
c = b.map {|a| a.length < 3 ? a : "#{a.first}-#{a.last}" }
p c # => [[1, 2], [4], "9-12", [15, 16], "19-21"]
d = c.join(",")
p d # =>...