ライブラリ
- ビルトイン (5436)
クラス
- Array (78)
- BasicObject (130)
- Binding (10)
- Class (40)
- Data (17)
- Dir (70)
-
Encoding
:: Converter (200) -
Encoding
:: InvalidByteSequenceError (20) -
Encoding
:: UndefinedConversionError (10) - Enumerator (141)
-
Enumerator
:: Chain (5) -
Enumerator
:: Lazy (10) -
Enumerator
:: Yielder (24) -
Errno
:: EXXX (20) - Exception (40)
- Fiber (48)
- File (89)
-
File
:: Stat (400) - FrozenError (10)
- Hash (155)
- IO (642)
- KeyError (32)
- LocalJumpError (20)
- Method (165)
- Module (243)
- Mutex (14)
- NameError (23)
- NoMethodError (15)
- Numeric (10)
- Object (366)
-
ObjectSpace
:: WeakMap (10) - Proc (47)
- Random (100)
- Range (40)
- Regexp (80)
-
RubyVM
:: InstructionSequence (30) - SignalException (30)
- StopIteration (10)
- String (45)
- Struct (285)
- SystemCallError (40)
- SystemExit (20)
- Thread (408)
-
Thread
:: Backtrace :: Location (40) -
Thread
:: ConditionVariable (24) -
Thread
:: Mutex (56) -
Thread
:: Queue (90) -
Thread
:: SizedQueue (56) - ThreadGroup (40)
- Time (52)
- TracePoint (135)
- UnboundMethod (18)
モジュール
- Enumerable (120)
-
GC
:: Profiler (10) - Kernel (249)
- Marshal (40)
- ObjectSpace (70)
オブジェクト
- ENV (22)
キーワード
- ! (10)
- != (10)
-
$ stdin (10) - < (10)
- << (10)
- <=> (30)
- == (71)
- === (36)
- ArgumentError (10)
- BasicObject (10)
- Complex (20)
- ConditionVariable (8)
- Data (7)
- EXXX (10)
- Enumerator (10)
- Fiber (10)
- Float (10)
- Integer (10)
- Location (10)
-
MAJOR
_ VERSION (10) -
MINOR
_ VERSION (10) - Method (10)
- Proc (10)
- Queue (8)
- Range (10)
- Rational (20)
- Regexp (10)
- SizedQueue (8)
- Stat (10)
- String (10)
- Struct (10)
- Symbol (1)
- Thread (10)
- ThreadGroup (10)
- TracePoint (10)
- UnboundMethod (10)
- UndefinedConversionError (10)
- Yielder (10)
- [] (72)
- []= (30)
-
_ _ id _ _ (10) -
_ _ send _ _ (20) -
_ dump (10) - abort (20)
-
abort
_ on _ exception (10) -
abort
_ on _ exception= (20) -
absolute
_ path (10) - add (10)
-
add
_ trace _ func (10) -
alias
_ method (10) - alive? (12)
- allocate (10)
- arity (10)
- atime (10)
- backtrace (10)
-
backtrace
_ locations (30) -
base
_ label (10) - bind (10)
-
bind
_ call (8) - binding (10)
- birthtime (9)
- blksize (10)
- blockdev? (10)
- blocks (10)
- broadcast (8)
- bytes (10)
- call (20)
-
callee
_ id (10) - casefold? (10)
- chardev? (10)
- chmod (10)
-
class
_ eval (20) -
class
_ exec (10) -
class
_ variable _ set (10) - clear (18)
- clone (10)
- close (26)
- closed? (18)
- coerce (10)
- compile (20)
-
compile
_ option= (10) - convert (10)
- convpath (10)
- ctime (10)
- current (2)
- deconstruct (1)
-
deconstruct
_ keys (1) - default (20)
-
default
_ proc (10) - define (2)
-
define
_ finalizer (20) -
define
_ method (20) -
defined
_ class (10) - deq (16)
-
destination
_ encoding (10) - dev (10)
-
dev
_ major (10) -
dev
_ minor (10) - dig (8)
- directory? (10)
- display (10)
- dump (20)
- dup (2)
- each (120)
-
each
_ char (20) -
each
_ entry (20) -
each
_ line (60) -
each
_ object (40) -
each
_ pair (20) -
each
_ with _ index (20) - empty? (8)
- enclose (10)
- enclosed? (10)
- entries (5)
-
enum
_ for (20) - eof (10)
- eof? (10)
- eql? (31)
- equal? (10)
-
error
_ bytes (10) -
error
_ char (10) -
eval
_ script (5) - event (10)
- exception (10)
- executable? (10)
-
executable
_ real? (10) - exit (10)
-
exit
_ value (10) - extend (10)
- extended (10)
- fail (30)
- feed (10)
- fetch (6)
- file? (10)
- filter (10)
- finish (10)
-
for
_ fd (10) - fork (10)
- ftype (10)
- getbyte (10)
- getc (10)
- gets (30)
- gid (10)
- grpowned? (10)
-
handle
_ interrupt (10) - hash (11)
-
ignore
_ deadlock= (3) -
incomplete
_ input? (10) - initialize (10)
-
initialize
_ copy (10) - ino (10)
-
insert
_ output (10) - inspect (81)
-
instance
_ eval (20) -
instance
_ exec (10) -
instance
_ method (10) -
instance
_ of? (10) -
instance
_ variable _ defined? (10) -
instance
_ variable _ get (10) -
instance
_ variable _ set (10) -
instance
_ variables (10) -
instruction
_ sequence (5) -
is
_ a? (10) - isatty (10)
- join (20)
- key (6)
-
keyword
_ init? (2) - kill (20)
-
kind
_ of? (10) - lambda (16)
- lambda? (10)
-
last
_ error (10) - length (18)
- lineno (20)
- lineno= (10)
- link (10)
- list (10)
-
local
_ variable _ set (10) - locked? (10)
- loop (16)
-
marshal
_ dump (20) -
marshal
_ load (10) - match (20)
- max (48)
- max= (8)
- members (21)
- merge (20)
-
method
_ id (10) -
method
_ missing (10) - methods (10)
- min (40)
- mode (10)
-
module
_ eval (20) -
module
_ exec (10) - mtime (10)
- name (20)
- name= (8)
-
new
_ seed (10) -
next
_ values (10) - nlink (10)
- now (10)
-
num
_ waiting (8) - open (80)
-
original
_ name (10) - owned? (20)
- owner (10)
- pack (14)
- parameters (15)
- pass (10)
- path (21)
-
peek
_ values (10) -
pending
_ interrupt? (10) - pipe (80)
- pipe? (10)
- pop (16)
- popen (140)
- prepend (10)
-
primitive
_ convert (40) -
primitive
_ errinfo (10) - priority (10)
- priority= (10)
- private (13)
- proc (17)
- produce (4)
- putback (20)
- raise (52)
-
raised
_ exception (10) - rand (30)
- rdev (10)
-
rdev
_ major (10) -
rdev
_ minor (10) - readable? (10)
-
readable
_ real? (10) - readchar (10)
- readline (30)
- reason (10)
- receiver (24)
- refine (10)
-
remove
_ instance _ variable (10) - reopen (30)
- replace (10)
- replacement (10)
- replacement= (10)
-
report
_ on _ exception (14) -
report
_ on _ exception= (14) -
respond
_ to? (10) -
respond
_ to _ missing? (10) - result (20)
- resume (10)
-
return
_ value (10) - rewind (10)
- run (10)
-
safe
_ level (7) -
search
_ convpath (10) - seed (10)
- seek (10)
- select (20)
- send (20)
-
set
_ trace _ func (10) - setgid? (10)
- setuid? (10)
- shift (26)
- shuffle (20)
- signal (8)
-
singleton
_ class (10) -
singleton
_ method (10) -
singleton
_ method _ added (10) -
singleton
_ method _ removed (10) -
singleton
_ method _ undefined (10) -
singleton
_ methods (10) - size (38)
- size? (10)
- sleep (30)
- socket? (10)
-
source
_ encoding (10) -
source
_ location (10) - start (10)
- status (20)
- sticky? (10)
- stop (10)
- stop? (10)
- store (10)
- strftime (10)
- sum (14)
-
super
_ method (9) - symlink (10)
- symlink? (10)
- sync= (10)
- synchronize (10)
- tainted? (6)
- terminate (10)
-
thread
_ variable _ get (10) -
thread
_ variable _ set (10) -
to
_ a (15) -
to
_ ary (10) -
to
_ enum (20) -
to
_ h (32) -
to
_ hash (10) -
to
_ int (10) -
to
_ path (1) -
to
_ proc (24) -
to
_ regexp (10) -
to
_ s (67) -
to
_ str (10) - trace (10)
-
trace
_ var (30) - transfer (2)
-
try
_ lock (10) - tty? (10)
- uid (10)
- unbind (10)
-
undef
_ method (10) -
undefine
_ finalizer (10) - ungetbyte (10)
- ungetc (10)
- unlock (10)
- utime (10)
- value (10)
- values (10)
-
values
_ at (20) - wakeup (10)
- wday (10)
- with (1)
-
with
_ index (20) -
with
_ object (20) - writable? (10)
-
writable
_ real? (10) - yield (20)
- zero? (10)
検索結果
先頭5件
-
Random
. new(seed = Random . new _ seed) -> Random (26230.0) -
メルセンヌ・ツイスタに基づく擬似乱数発生装置オブジェクトを作ります。 引数が省略された場合は、Random.new_seedの値を使用します。
...。
引数が省略された場合は、Random.new_seedの値を使用します。
@param seed 擬似乱数生成器の種を整数で指定します。
//emlist[例: 種が同じなら同じ乱数列を発生できる。][ruby]{
prng = Random.new(1234)
[ prng.ra......] #=> [0.1915194503788923, 0.6221087710398319]
[ prng.rand(10), prng.rand(1000) ] #=> [4, 664]
# 同じ乱数列を発生する。
prng = Random.new(1234)
[ prng.rand, prng.rand ] #=> [0.1915194503788923, 0.6221087710398319]
[ prng.rand(10), prng.rand(1000) ] #... -
Range
. new(first , last , exclude _ end = false) -> Range (26167.0) -
first から last までの範囲オブジェクトを生成して返しま す。
...[例: 整数の範囲オブジェクトの場合][ruby]{
Range.new(1, 10) # => 1..10
Range.new(1, 10, true) # => 1...10
//}
//emlist[例: 日付オブジェクトの範囲オブジェクトの場合][ruby]{
require 'date'
Range.new(Date.today, Date.today >> 1).each {|d| puts d }
# => 2017-09-......y]{
require 'ipaddr'
Range.new(IPAddr.new("192.0.2.1"), IPAddr.new("192.0.2.3")).each {|ip| puts ip}
# => 192.0.2.1
# 192.0.2.2
# 192.0.2.3
//}
//emlist[例: 自作のオブジェクトの場合][ruby]{
MyInteger = Struct.new(:value) do
def succ
self.class.new(value + 1)
end
def <=......>(other)
value <=> other.value
end
def to_s
value.to_s
end
end
Range.new(MyInteger.new(1), MyInteger.new(3)).each {|i| puts i }
# => 1
# 2
# 3
//}... -
Proc
. new -> Proc (26132.0) -
ブロックをコンテキストとともにオブジェクト化して返します。
...クを指定しない場合、Ruby 2.7 では
$VERBOSE = true のときには警告メッセージ
「warning: Capturing the given block using Proc.new is deprecated; use `&block` instead」
が出力され、Ruby 3.0 では
ArgumentError (tried to create Proc object without a block)
が発生しま......ブロックがないのにブロックを省略した呼び出しを行ったときに発生します。
//emlist[例][ruby]{
def foo
pr = Proc.new
pr.call(1)
end
foo {|arg| p arg }
# => 1
//}
これは以下と同じです。
//emlist[例][ruby]{
def foo
yield(1)
end
foo {|arg| p arg }
#......umentError が発生します。
//emlist[例][ruby]{
def foo
Proc.new
end
foo
# => -:2:in `new': tried to create Proc object without a block (ArgumentError)
# from -:2:in `foo'
# from -:4:in `<main>'
//}
Proc.new は、Proc#initialize が定義されていれば
オブジェクト... -
Proc
. new { . . . } -> Proc (26132.0) -
ブロックをコンテキストとともにオブジェクト化して返します。
...クを指定しない場合、Ruby 2.7 では
$VERBOSE = true のときには警告メッセージ
「warning: Capturing the given block using Proc.new is deprecated; use `&block` instead」
が出力され、Ruby 3.0 では
ArgumentError (tried to create Proc object without a block)
が発生しま......ブロックがないのにブロックを省略した呼び出しを行ったときに発生します。
//emlist[例][ruby]{
def foo
pr = Proc.new
pr.call(1)
end
foo {|arg| p arg }
# => 1
//}
これは以下と同じです。
//emlist[例][ruby]{
def foo
yield(1)
end
foo {|arg| p arg }
#......umentError が発生します。
//emlist[例][ruby]{
def foo
Proc.new
end
foo
# => -:2:in `new': tried to create Proc object without a block (ArgumentError)
# from -:2:in `foo'
# from -:4:in `<main>'
//}
Proc.new は、Proc#initialize が定義されていれば
オブジェクト... -
Hash
. new(ifnone = nil) -> Hash (26129.0) -
空の新しいハッシュを生成します。ifnone はキーに対 応する値が存在しない時のデフォルト値です。設定したデフォルト値はHash#defaultで参照できます。
...省略した Hash.new は {} と同じです。
デフォルト値として、毎回同一のオブジェクトifnoneを返します。
それにより、一箇所のデフォルト値の変更が他の値のデフォルト値にも影響します。
//emlist[][ruby]{
h = Hash.new([])
h[0] << 0
h[......[ruby]{
h = Hash.new([])
p h[1] #=> []
p h[1].object_id #=> 6127150
p h[1] << "bar" #=> ["bar"]
p h[1] #=> ["bar"]
p h[2] #=> ["bar"]
p h[2].object_id #=> 6127150
p h #=> {}
h = Hash.new([].freeze)
h[0]... -
Encoding
:: Converter . new(convpath) -> Encoding :: Converter (26127.0) -
Encoding::Converter オブジェクトを作成します。
...onverter::UNDEF_REPLACE
* Encoding::Converter::UNDEF_HEX_CHARREF
* Encoding::Converter::UNIVERSAL_NEWLINE_DECORATOR
* Encoding::Converter::CRLF_NEWLINE_DECORATOR
* Encoding::Converter::CR_NEWLINE_DECORATOR
* Encoding::Converter::XML_TEXT_DECORATOR
* Encoding::Converter::XML_ATTR_CONTENT_......oding::Converter.new("UTF-16BE", "UTF-8")
# Usually, decorators such as newline conversion are inserted last.
ec = Encoding::Converter.new("UTF-16BE", "UTF-8", :universal_newline => true)
p ec.convpath #=> [[#<Encoding:UTF-16BE>, #<Encoding:UTF-8>],
# "universal_newline"]
# But, i......ersion.
ec = Encoding::Converter.new("UTF-8", "UTF-16BE", :crlf_newline => true)
p ec.convpath #=> ["crlf_newline",
# [#<Encoding:UTF-8>, #<Encoding:UTF-16BE>]]
# Conversion path can be specified directly.
ec = Encoding::Converter.new(["universal_newline", ["EUC-JP", "UTF-8"], ["UT... -
Encoding
:: Converter . new(source _ encoding , destination _ encoding) -> Encoding :: Converter (26127.0) -
Encoding::Converter オブジェクトを作成します。
...onverter::UNDEF_REPLACE
* Encoding::Converter::UNDEF_HEX_CHARREF
* Encoding::Converter::UNIVERSAL_NEWLINE_DECORATOR
* Encoding::Converter::CRLF_NEWLINE_DECORATOR
* Encoding::Converter::CR_NEWLINE_DECORATOR
* Encoding::Converter::XML_TEXT_DECORATOR
* Encoding::Converter::XML_ATTR_CONTENT_......oding::Converter.new("UTF-16BE", "UTF-8")
# Usually, decorators such as newline conversion are inserted last.
ec = Encoding::Converter.new("UTF-16BE", "UTF-8", :universal_newline => true)
p ec.convpath #=> [[#<Encoding:UTF-16BE>, #<Encoding:UTF-8>],
# "universal_newline"]
# But, i......ersion.
ec = Encoding::Converter.new("UTF-8", "UTF-16BE", :crlf_newline => true)
p ec.convpath #=> ["crlf_newline",
# [#<Encoding:UTF-8>, #<Encoding:UTF-16BE>]]
# Conversion path can be specified directly.
ec = Encoding::Converter.new(["universal_newline", ["EUC-JP", "UTF-8"], ["UT... -
Encoding
:: Converter . new(source _ encoding , destination _ encoding , options) -> Encoding :: Converter (26127.0) -
Encoding::Converter オブジェクトを作成します。
...onverter::UNDEF_REPLACE
* Encoding::Converter::UNDEF_HEX_CHARREF
* Encoding::Converter::UNIVERSAL_NEWLINE_DECORATOR
* Encoding::Converter::CRLF_NEWLINE_DECORATOR
* Encoding::Converter::CR_NEWLINE_DECORATOR
* Encoding::Converter::XML_TEXT_DECORATOR
* Encoding::Converter::XML_ATTR_CONTENT_......oding::Converter.new("UTF-16BE", "UTF-8")
# Usually, decorators such as newline conversion are inserted last.
ec = Encoding::Converter.new("UTF-16BE", "UTF-8", :universal_newline => true)
p ec.convpath #=> [[#<Encoding:UTF-16BE>, #<Encoding:UTF-8>],
# "universal_newline"]
# But, i......ersion.
ec = Encoding::Converter.new("UTF-8", "UTF-16BE", :crlf_newline => true)
p ec.convpath #=> ["crlf_newline",
# [#<Encoding:UTF-8>, #<Encoding:UTF-16BE>]]
# Conversion path can be specified directly.
ec = Encoding::Converter.new(["universal_newline", ["EUC-JP", "UTF-8"], ["UT... -
Class
. new(superclass = Object) -> Class (26126.0) -
新しく名前の付いていない superclass のサブクラスを生成します。
...める際に代入されている定数名を検
索し、見つかった定数名をクラス名とします。
//emlist[例][ruby]{
p foo = Class.new # => #<Class:0x401b90f8>
p foo.name # => nil
Foo = foo # ここで p foo すれば "Foo" 固定
Bar = foo
p foo.name......s.new(superclass)
klass.module_eval {|m|
# ...
}
klass
//}
この場合も生成したクラスを返します。
ブロックの実行は Class#initialize が行います。
@param superclass 生成するクラスのスーパークラスを指定します。
//emlist[例][ruby]{
k = Class.new{......|c|
def initialize
p "in initialize"
end
def hoge
p "hoge hoge hoge"
end
}
o = k.new #=> "in initialize"
o.hoge #=> "hoge hoge hoge"
//}... -
Class
. new(superclass = Object) {|klass| . . . } -> Class (26126.0) -
新しく名前の付いていない superclass のサブクラスを生成します。
...める際に代入されている定数名を検
索し、見つかった定数名をクラス名とします。
//emlist[例][ruby]{
p foo = Class.new # => #<Class:0x401b90f8>
p foo.name # => nil
Foo = foo # ここで p foo すれば "Foo" 固定
Bar = foo
p foo.name......s.new(superclass)
klass.module_eval {|m|
# ...
}
klass
//}
この場合も生成したクラスを返します。
ブロックの実行は Class#initialize が行います。
@param superclass 生成するクラスのスーパークラスを指定します。
//emlist[例][ruby]{
k = Class.new{......|c|
def initialize
p "in initialize"
end
def hoge
p "hoge hoge hoge"
end
}
o = k.new #=> "in initialize"
o.hoge #=> "hoge hoge hoge"
//}... -
Proc
. new { . . . } -> Proc (26125.0) -
ブロックをコンテキストとともにオブジェクト化して返します。
...を行ったときに発生します。
//emlist[][ruby]{
pr = Proc.new {|arg| p arg }
pr.call(1) # => 1
//}
//emlist[][ruby]{
Proc.new # => -e:1:in `new': tried to create Proc object without a block (ArgumentError)
//}
Proc.new は、Proc#initialize が定義されていれば
オブジェクト... -
ThreadGroup
. new -> ThreadGroup (26125.0) -
新たな ThreadGroup を生成して返します。
...な ThreadGroup を生成して返します。
//emlist[例][ruby]{
thread_group = ThreadGroup.new
thread_group.add Thread.new { sleep 0.1; Thread.new { sleep 1 }; sleep 1 }
thread_group.add Thread.new { sleep 2 }
sleep 0.5
thread_group.list # => [#<Thread:0x007fc6f1842d70 sleep>, #<Thread:0x007fc6...