383件ヒット
[1-100件を表示]
(0.137秒)
種類
- インスタンスメソッド (278)
- 特異メソッド (61)
- 変数 (44)
クラス
- Array (88)
- BasicObject (11)
-
Encoding
:: Converter (44) - Hash (89)
- IO (22)
- Object (44)
-
RubyVM
:: InstructionSequence (33) - String (2)
モジュール
- Kernel (44)
オブジェクト
- ENV (6)
検索結果
-
ENV
. dup -> () (29103.0) -
TypeErrorを発生させます。
...TypeErrorを発生させます。
3.0 以前では Object.new と同様の ENV とは無関係の有用ではないオブジェクトを返していたため、3.1 からは例外が発生するようになりました。
詳細はENV.cloneを参照してください。
@see ENV.clone... -
Object
# dup -> object (26233.0) -
オブジェクトの複製を作成して返します。
...す。
dup はオブジェクトの内容, taint 情報をコピーし、
clone はそれに加えて freeze, 特異メソッドなどの情報も含めた完全な複製を作成します。
clone や dup は浅い(shallow)コピーであることに注意してください。後述。
TrueClass......, FalseClass, NilClass, Symbol, そして Numeric クラスのインスタンスなど一部のオブジェクトは複製ではなくインスタンス自身を返します。
@param freeze false を指定すると freeze されていないコピーを返します。
@raise ArgumentError TrueClass......freeze されているオブジェクトの freeze されていないコピーを作成しようとしたときに発生します。
//emlist[][ruby]{
obj = "string"
obj.taint
def obj.fuga
end
obj.freeze
p(obj.equal?(obj)) #=> true
p(obj == obj) #=> true
p(obj.tainted?)......す。
dup はオブジェクトの内容をコピーし、
clone はそれに加えて freeze, 特異メソッドなどの情報も含めた完全な複製を作成します。
clone や dup は浅い(shallow)コピーであることに注意してください。後述。
TrueClass, FalseClass,......して Numeric クラスのインスタンスなど一部のオブジェクトは複製ではなくインスタンス自身を返します。
@param freeze false を指定すると freeze されていないコピーを返します。
@raise ArgumentError TrueClass などの常に freeze されて......freeze されていないコピーを作成しようとしたときに発生します。
//emlist[][ruby]{
obj = "string"
def obj.fuga
end
obj.freeze
p(obj.equal?(obj)) #=> true
p(obj == obj) #=> true
p(obj.frozen?) #=> true
p(obj.respond_to?(:fuga)) #=> true... -
IO
# dup -> IO (26125.0) -
レシーバと同じ IO を参照する新しい IO オブジェクトを返します。 参照しているファイル記述子は dup(2) されます。
...述子は dup(2) されます。
clone の際に self は一旦 IO#flush されます。
フリーズした IO の clone は同様にフリーズされた IO を返しますが、
dup は内容の等しいフリーズされていない IO を返します。
@raise IOError 既に close されてい......た場合に発生します。
//emlist[例][ruby]{
clone_io = nil
IO.write("testfile", "test")
File.open("testfile") do |io|
clone_io = io.clone
end
clone_io.read # => "test"
clone_io.close
//}... -
Array
# dup -> Array (26115.0) -
レシーバと同じ内容を持つ新しい配列を返します。
...レシーバと同じ内容を持つ新しい配列を返します。
clone は frozen singleton-class の情報も含めてコピーしますが、
dup は内容と tainted だけをコピーします。
またどちらのメソッドも要素それ自体のコピーはしません。
つまり......参照しているオブジェクトが変わらない「浅い(shallow)」コピーを行います。
//emlist[例][ruby]{
ary = ['string']
p ary #=> ["string"]
copy = ary.dup
p copy #=> ["string"]
ary[0][0...3] = ''
p ary #=> ["ing"]
p copy #=> ["ing......レシーバと同じ内容を持つ新しい配列を返します。
clone は frozen singleton-class の情報も含めてコピーしますが、
dup は内容だけをコピーします。
またどちらのメソッドも要素それ自体のコピーはしません。
つまり参照して......いるオブジェクトが変わらない「浅い(shallow)」コピーを行います。
//emlist[例][ruby]{
ary = ['string']
p ary #=> ["string"]
copy = ary.dup
p copy #=> ["string"]
ary[0][0...3] = ''
p ary #=> ["ing"]
p copy #=> ["ing"]
//}... -
Hash
# dup -> Hash (26115.0) -
selfと同じ内容を持つ新しいハッシュを返します。
...selfと同じ内容を持つ新しいハッシュを返します。
clone は frozen singleton-class の情報も含めてコピーしますが、
dup は内容と tainted だけをコピーします。
またどちらのメソッドも要素それ自体のコピーはしません。
つまり参......//emlist[例][ruby]{
h1 = {"have" => "have a","as" => "as a" }
h2 = h1.dup
h2["have"] = "has"
p h2 #=> {"have"=>"has", "as"=>"as a"}
p h1 #=> {"have"=>"have a", "as"=>"as a"}
h2["as"].upcase!
p h2 #=> {"have"=>"has", "as"=>"AS A"}
p h1 #=> {"have"=>"have a", "as"=>"AS A"}
//}
@see Object#clone......selfと同じ内容を持つ新しいハッシュを返します。
clone は frozen singleton-class の情報も含めてコピーしますが、
dup は内容だけをコピーします。
またどちらのメソッドも要素それ自体のコピーはしません。
つまり参照してい... -
Kernel
$ $ stderr -> object (17108.0) -
標準エラー出力です。
...ンタプリタが出力するエラーメッセージや
警告メッセージ、Kernel.#warn の出力先となります。
初期値は Object::STDERR です。
$stderr に代入するオブジェクトには
write という名前のメソッドが定義されていなければいけません。......リダイレクトしたいときには、
$stderr に代入すれば十分です。
//emlist[例][ruby]{
# 標準エラー出力の出力先を /tmp/foo に変更
$stderr = File.open("/tmp/foo", "w")
puts "foo" # 出力する
$stderr = STDERR # 元に戻す
//}
自プロセスだけで......eopen を使います。
//emlist[例][ruby]{
$stderr.reopen("/tmp/foo", "w")
//}
また、リダイレクトしたあと
出力先をまた元に戻したい場合は以下のようにします。
//emlist[例][ruby]{
stderr_old = $stderr.dup # 元の $stderr を保存する
$stderr.reope... -
Hash
# filter! -> Enumerator (14226.0) -
キーと値を引数としてブロックを評価した結果が真であるような要素を self に残します。
...self
に残します。
keep_if は常に self を返します。
filter! と select! はオブジェクトが変更された場合に self を、
されていない場合に nil を返します。
ブロックが与えられなかった場合は、自身と keep_if から生成した
Enumerator......す。
//emlist[例][ruby]{
h1 = {}
c = ("a".."g")
c.each_with_index {|e, i| h1[i] = e }
h2 = h1.dup
h1.select! # => #<Enumerator: {0=>"a", 1=>"b", 2=>"c", 3=>"d", 4=>"e", 5=>"f", 6=>"g"}:select!>
h1.select! { |k, v| k % 3 == 0 } # => {0=>"a", 3=>"d", 6=>"g"}
h1.select! { |k, v| true } #......=> nil
h2.keep_if { |k, v| k % 3 == 0 } # => {0=>"a", 3=>"d", 6=>"g"}
h2.keep_if { |k, v| true } # => {0=>"a", 3=>"d", 6=>"g"}
//}
@see Hash#select, Hash#delete_if, Hash#reject!... -
Hash
# select! {|key , value| . . . } -> self | nil (14226.0) -
キーと値を引数としてブロックを評価した結果が真であるような要素を self に残します。
...素を self
に残します。
keep_if は常に self を返します。
select! はオブジェクトが変更された場合に self を、
されていない場合に nil を返します。
ブロックが与えられなかった場合は、自身と keep_if から生成した
Enumerator オブ......す。
//emlist[例][ruby]{
h1 = {}
c = ("a".."g")
c.each_with_index {|e, i| h1[i] = e }
h2 = h1.dup
h1.select! # => #<Enumerator: {0=>"a", 1=>"b", 2=>"c", 3=>"d", 4=>"e", 5=>"f", 6=>"g"}:select!>
h1.select! { |k, v| k % 3 == 0 } # => {0=>"a", 3=>"d", 6=>"g"}
h1.select! { |k, v| true } #......=> nil
h2.keep_if { |k, v| k % 3 == 0 } # => {0=>"a", 3=>"d", 6=>"g"}
h2.keep_if { |k, v| true } # => {0=>"a", 3=>"d", 6=>"g"}
//}
@see Hash#select, Hash#delete_if, Hash#reject!......self
に残します。
keep_if は常に self を返します。
filter! と select! はオブジェクトが変更された場合に self を、
されていない場合に nil を返します。
ブロックが与えられなかった場合は、自身と keep_if から生成した
Enumerator... -
Encoding
:: Converter # primitive _ convert(source _ buffer , destination _ buffer) -> Symbol (14208.0) -
エンコーディング変換のためのメソッドの中で、もっとも細かな扱いが可能なメソッドです。
...Encoding::Converter#primitive_convert が唯一の方法になります。
@param source_buffer 変換元文字列のバッファ
@param destination_buffer 変換先文字列を格納するバッファ
@param destination_byteoffset 変換先バッファでのオフセット
@param destination_bytes......ze 変換先バッファの容量
@param options 変換の詳細を指定する定数やハッシュ
@return 変換結果を表す Symbol
options には以下が指定できます。
: hash form
:partial_input => true # source buffer may be part of larger source
:after_output => true......op conversion after output before input
: integer form
Encoding::Converter::PARTIAL_INPUT
Encoding::Converter::AFTER_OUTPUT
戻り値は以下のうちのどれかです。
* :invalid_byte_sequence
* :incomplete_input
* :undefined_conversion
* :after_output
* :destination_buffer_full... -
Encoding
:: Converter # primitive _ convert(source _ buffer , destination _ buffer , destination _ byteoffset) -> Symbol (14208.0) -
エンコーディング変換のためのメソッドの中で、もっとも細かな扱いが可能なメソッドです。
...Encoding::Converter#primitive_convert が唯一の方法になります。
@param source_buffer 変換元文字列のバッファ
@param destination_buffer 変換先文字列を格納するバッファ
@param destination_byteoffset 変換先バッファでのオフセット
@param destination_bytes......ze 変換先バッファの容量
@param options 変換の詳細を指定する定数やハッシュ
@return 変換結果を表す Symbol
options には以下が指定できます。
: hash form
:partial_input => true # source buffer may be part of larger source
:after_output => true......op conversion after output before input
: integer form
Encoding::Converter::PARTIAL_INPUT
Encoding::Converter::AFTER_OUTPUT
戻り値は以下のうちのどれかです。
* :invalid_byte_sequence
* :incomplete_input
* :undefined_conversion
* :after_output
* :destination_buffer_full... -
Encoding
:: Converter # primitive _ convert(source _ buffer , destination _ buffer , destination _ byteoffset , destination _ bytesize) -> Symbol (14208.0) -
エンコーディング変換のためのメソッドの中で、もっとも細かな扱いが可能なメソッドです。
...Encoding::Converter#primitive_convert が唯一の方法になります。
@param source_buffer 変換元文字列のバッファ
@param destination_buffer 変換先文字列を格納するバッファ
@param destination_byteoffset 変換先バッファでのオフセット
@param destination_bytes......ze 変換先バッファの容量
@param options 変換の詳細を指定する定数やハッシュ
@return 変換結果を表す Symbol
options には以下が指定できます。
: hash form
:partial_input => true # source buffer may be part of larger source
:after_output => true......op conversion after output before input
: integer form
Encoding::Converter::PARTIAL_INPUT
Encoding::Converter::AFTER_OUTPUT
戻り値は以下のうちのどれかです。
* :invalid_byte_sequence
* :incomplete_input
* :undefined_conversion
* :after_output
* :destination_buffer_full...