1361件ヒット
[1-100件を表示]
(0.248秒)
ライブラリ
- ビルトイン (1361)
クラス
- Array (33)
- Class (22)
- Data (12)
- Dir (66)
-
Encoding
:: Converter (44) - Enumerator (23)
-
Enumerator
:: Chain (6) -
Enumerator
:: Lazy (11) -
Errno
:: EXXX (22) - Exception (22)
- Fiber (25)
- File (77)
-
File
:: Stat (11) - FrozenError (12)
- Hash (44)
- IO (286)
- KeyError (24)
- Module (22)
- Mutex (2)
- NameError (17)
- NoMethodError (17)
- Object (11)
- Proc (18)
- Random (22)
- Range (11)
- Regexp (22)
-
RubyVM
:: InstructionSequence (33) - SignalException (33)
- String (28)
- Struct (58)
- SystemCallError (44)
- SystemExit (11)
- Thread (126)
-
Thread
:: ConditionVariable (9) -
Thread
:: Mutex (9) -
Thread
:: Queue (12) -
Thread
:: SizedQueue (9) - ThreadGroup (11)
- Time (38)
- TracePoint (22)
モジュール
-
GC
:: Profiler (11)
オブジェクト
- ENV (25)
キーワード
- === (11)
- [] (37)
- []= (11)
-
abort
_ on _ exception= (11) - compile (22)
-
compile
_ option= (11) - current (3)
- define (4)
- dup (3)
- exception (11)
-
for
_ fd (11) - fork (11)
-
handle
_ interrupt (11) -
keyword
_ init? (3) - kill (11)
- link (11)
- list (11)
- members (11)
-
new
_ seed (11) - now (11)
- open (88)
- pass (11)
- path (11)
-
pending
_ interrupt? (11) - pipe (88)
- popen (154)
- produce (5)
-
report
_ on _ exception (8) -
report
_ on _ exception= (8) - result (11)
-
search
_ convpath (11) - start (11)
- stop (11)
- store (11)
- symlink (11)
- trace (11)
- utime (11)
- yield (11)
検索結果
先頭5件
-
Random
. new(seed = Random . new _ seed) -> Random (26231.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 (26168.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 (26133.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 (26133.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 (26130.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 (26128.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 (26128.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 (26128.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 (26127.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 (26127.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"
//}...