158件ヒット
[1-100件を表示]
(0.297秒)
種類
- インスタンスメソッド (155)
- 特異メソッド (3)
ライブラリ
- ビルトイン (158)
クラス
- BasicObject (11)
-
Encoding
:: Converter (44) - Hash (56)
- Object (42)
- String (2)
オブジェクト
- ENV (3)
キーワード
- clone (14)
- dedup (2)
- equal? (11)
- filter! (12)
- freeze (11)
-
initialize
_ copy (9) -
keep
_ if (22) -
primitive
_ convert (44) - select! (22)
検索結果
先頭5件
-
Object
# dup -> object (23198.0) -
オブジェクトの複製を作成して返します。
...す。
dup はオブジェクトの内容, taint 情報をコピーし、
clone はそれに加えて freeze, 特異メソッドなどの情報も含めた完全な複製を作成します。
clone や dup は浅い(shallow)コピーであることに注意してください。後述。
TrueClass......se 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?) #=> true
p(obj.frozen?) #=> true
p(obj.respond_to?(:fuga)) #=> true
obj_c = obj.clone
p(obj.equal?(obj_c)) #=> false
p(obj == obj_c) #=> true
p(obj_c.tainted?) #=> true
p(obj_c.frozen?) #=> true
p(obj_......#=> true
p(obj.tainted?) #=> false
p(obj.frozen?) #=> true
p(obj.respond_to?(:fuga)) #=> true
obj_c = obj.clone
p(obj.equal?(obj_c)) #=> false
p(obj == obj_c) #=> true
p(obj_c.tainted?) #=> false
p(obj_c.frozen?) #=> true
p(obj......します。
dup はオブジェクトの内容をコピーし、
clone はそれに加えて freeze, 特異メソッドなどの情報も含めた完全な複製を作成します。
clone や dup は浅い(shallow)コピーであることに注意してください。後述。
TrueClass, FalseC......or 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
obj_c = obj.clone
p(obj.equal?(obj_c)) #=> false
p(obj == obj_c) #=> true
p(obj_c.frozen?) #=> true
p(obj_c.respond_to?(:fuga)) #=> true
obj_d = obj.dup
p(obj.equal?(obj_d)) #=> false
p(... -
String
# dedup -> String | self (11130.0) -
self が freeze されている文字列の場合、self を返します。 freeze されていない場合は元の文字列の freeze された (できる限り既存の) 複製を返します。
...=> true
original_text == frozen_text # => true
original_text.equal?(frozen_text) # => false
original_text = "text".freeze
frozen_text = -original_text
frozen_text.frozen? # => true
original_text == frozen_text # => true
original_text.equal?(frozen_text) # => true
/... -
Object
# clone(freeze: true) -> object (8198.0) -
オブジェクトの複製を作成して返します。
...す。
dup はオブジェクトの内容, taint 情報をコピーし、
clone はそれに加えて freeze, 特異メソッドなどの情報も含めた完全な複製を作成します。
clone や dup は浅い(shallow)コピーであることに注意してください。後述。
TrueClass......se 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?) #=> true
p(obj.frozen?) #=> true
p(obj.respond_to?(:fuga)) #=> true
obj_c = obj.clone
p(obj.equal?(obj_c)) #=> false
p(obj == obj_c) #=> true
p(obj_c.tainted?) #=> true
p(obj_c.frozen?) #=> true
p(obj_......#=> true
p(obj.tainted?) #=> false
p(obj.frozen?) #=> true
p(obj.respond_to?(:fuga)) #=> true
obj_c = obj.clone
p(obj.equal?(obj_c)) #=> false
p(obj == obj_c) #=> true
p(obj_c.tainted?) #=> false
p(obj_c.frozen?) #=> true
p(obj......します。
dup はオブジェクトの内容をコピーし、
clone はそれに加えて freeze, 特異メソッドなどの情報も含めた完全な複製を作成します。
clone や dup は浅い(shallow)コピーであることに注意してください。後述。
TrueClass, FalseC......or 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
obj_c = obj.clone
p(obj.equal?(obj_c)) #=> false
p(obj == obj_c) #=> true
p(obj_c.frozen?) #=> true
p(obj_c.respond_to?(:fuga)) #=> true
obj_d = obj.dup
p(obj.equal?(obj_d)) #=> false
p(... -
ENV
. clone(freeze: true) -> object (8107.0) -
ENV オブジェクトの複製を作成して返します。
...複製で環境変数を操作するときに deprecated 警告がでます。
テスト実行中に環境変数を退避する用途には ENV.to_h を使用してください。
//emlist[][ruby]{
saved_env = ENV.to_h
# (テストなど)
ENV.replace(saved_env)
//}
@see Object#clone
@see ENV.dup... -
Object
# initialize _ copy(obj) -> object (8048.0) -
(拡張ライブラリによる) ユーザ定義クラスのオブジェクトコピーの初期化メソッド。
...obj の内容で置き換えます。ただ
し、self のインスタンス変数や特異メソッドは変化しません。
Object#clone, Object#dupの内部で使われています。
initialize_copy は、Ruby インタプリタが知り得ない情報をコピーするた
めに使用(定義......保持させない場合がありますが、そういった内部情
報を initialize_copy でコピーするよう定義しておくことで、dup や clone
を再定義する必要がなくなります。
デフォルトの Object#initialize_copy は、 freeze チェックおよび型のチェ......バ
のクラスと異なる場合に発生します。
@see Object#clone,Object#dup
以下に例として、dup や clone がこのメソッドをどのように利用しているかを示します。
obj.dup は、新たに生成したオブジェクトに対して
initialize_copy を呼び
/... -
BasicObject
# equal?(other) -> bool (8024.0) -
オブジェクトが other と同一であれば真を、さもなくば偽を返します。
...さもなくば偽
//emlist[例][ruby]{
original = "a"
copied = original.dup
substituted = original
original == copied #=> true
original == substituted #=> true
original.equal? copied #=> false
original.equal? substituted #=> true
//}
@see Object#equal?, Object#==, Object#eql?... -
Object
# freeze -> self (8024.0) -
オブジェクトを凍結(内容の変更を禁止)します。
...ませんが、Object#dup を使えばほぼ同じ内容の凍結されていない
オブジェクトを得ることはできます。
//emlist[][ruby]{
a = [1].freeze
p a.frozen? #=> true
a[0] = "foo"
p a # can't modify frozen Array (RuntimeError)
b = a.dup
p b #=> [......1]
p b.frozen? #=> false
b[0] = "foo"
p b #=> ["foo"]
//}
@see Object#frozen?,Object#dup,Kernel.#trace_var......ませんが、Object#dup を使えばほぼ同じ内容の凍結されていない
オブジェクトを得ることはできます。
//emlist[][ruby]{
a = [1].freeze
p a.frozen? #=> true
a[0] = "foo"
p a # can't modify frozen Array (FrozenError)
b = a.dup
p b #=> [1......]
p b.frozen? #=> false
b[0] = "foo"
p b #=> ["foo"]
//}
@see Object#frozen?,Object#dup,Kernel.#trace_var... -
Encoding
:: Converter # primitive _ convert(source _ buffer , destination _ buffer) -> Symbol (8018.0) -
エンコーディング変換のためのメソッドの中で、もっとも細かな扱いが可能なメソッドです。
...変換結果を表す Symbol
options には以下が指定できます。
: hash form
:partial_input => true # source buffer may be part of larger source
:after_output => true # stop conversion after output before input
: integer form
Encoding::Converter::PARTIAL_INPUT......nvalid_byte_sequence
ec.insert_output(ec.primitive_errinfo[3].dump[1..-2])
redo
when :undefined_conversion
c = ec.primitive_errinfo[3].dup.force_encoding(ec.primitive_errinfo[1])
ec.insert_output('\x{%X:%s}' % [c.ord, c.encoding])
redo
when :incomplete_input
ec.insert_out... -
Encoding
:: Converter # primitive _ convert(source _ buffer , destination _ buffer , destination _ byteoffset) -> Symbol (8018.0) -
エンコーディング変換のためのメソッドの中で、もっとも細かな扱いが可能なメソッドです。
...変換結果を表す Symbol
options には以下が指定できます。
: hash form
:partial_input => true # source buffer may be part of larger source
:after_output => true # stop conversion after output before input
: integer form
Encoding::Converter::PARTIAL_INPUT......nvalid_byte_sequence
ec.insert_output(ec.primitive_errinfo[3].dump[1..-2])
redo
when :undefined_conversion
c = ec.primitive_errinfo[3].dup.force_encoding(ec.primitive_errinfo[1])
ec.insert_output('\x{%X:%s}' % [c.ord, c.encoding])
redo
when :incomplete_input
ec.insert_out... -
Encoding
:: Converter # primitive _ convert(source _ buffer , destination _ buffer , destination _ byteoffset , destination _ bytesize) -> Symbol (8018.0) -
エンコーディング変換のためのメソッドの中で、もっとも細かな扱いが可能なメソッドです。
...変換結果を表す Symbol
options には以下が指定できます。
: hash form
:partial_input => true # source buffer may be part of larger source
:after_output => true # stop conversion after output before input
: integer form
Encoding::Converter::PARTIAL_INPUT......nvalid_byte_sequence
ec.insert_output(ec.primitive_errinfo[3].dump[1..-2])
redo
when :undefined_conversion
c = ec.primitive_errinfo[3].dup.force_encoding(ec.primitive_errinfo[1])
ec.insert_output('\x{%X:%s}' % [c.ord, c.encoding])
redo
when :incomplete_input
ec.insert_out... -
Encoding
:: Converter # primitive _ convert(source _ buffer , destination _ buffer , destination _ byteoffset , destination _ bytesize , options) -> Symbol (8018.0) -
エンコーディング変換のためのメソッドの中で、もっとも細かな扱いが可能なメソッドです。
...変換結果を表す Symbol
options には以下が指定できます。
: hash form
:partial_input => true # source buffer may be part of larger source
:after_output => true # stop conversion after output before input
: integer form
Encoding::Converter::PARTIAL_INPUT......nvalid_byte_sequence
ec.insert_output(ec.primitive_errinfo[3].dump[1..-2])
redo
when :undefined_conversion
c = ec.primitive_errinfo[3].dup.force_encoding(ec.primitive_errinfo[1])
ec.insert_output('\x{%X:%s}' % [c.ord, c.encoding])
redo
when :incomplete_input
ec.insert_out...