481件ヒット
[101-200件を表示]
(0.117秒)
ライブラリ
- ビルトイン (456)
-
minitest
/ spec (1) - pp (24)
キーワード
- === (12)
-
_ dump (12) - clone (12)
-
define
_ singleton _ method (24) - display (12)
- dup (12)
-
enum
_ for (24) - extend (12)
- initialize (12)
-
initialize
_ copy (12) - inspect (12)
-
instance
_ of? (12) -
instance
_ variable _ defined? (12) -
instance
_ variable _ get (12) -
is
_ a? (12) -
kind
_ of? (12) -
marshal
_ dump (12) - methods (12)
-
must
_ send (1) -
pretty
_ print (12) -
pretty
_ print _ cycle (12) -
public
_ send (24) -
remove
_ instance _ variable (12) -
respond
_ to? (12) -
respond
_ to _ missing? (12) - send (24)
-
singleton
_ method (12) -
singleton
_ methods (12) -
to
_ ary (12) -
to
_ enum (24) -
to
_ hash (12) -
to
_ int (12) -
to
_ proc (12) -
to
_ regexp (12) -
to
_ s (12) -
to
_ str (12)
検索結果
先頭5件
-
Object
# enum _ for(method = :each , *args) -> Enumerator (32.0) -
Enumerator.new(self, method, *args) を返します。
...# size メソッドが nil でなければ size * n を返す。
sz = size
sz * n if sz
end
end
each do |*val|
n.times { yield *val }
end
end
end
%i[hello world].repeat(2) { |w| puts w }
# => 'hello', 'hello', 'world', 'world'
enum = (1..14).repeat(3)... -
Object
# enum _ for(method = :each , *args) {|*args| . . . } -> Enumerator (32.0) -
Enumerator.new(self, method, *args) を返します。
...# size メソッドが nil でなければ size * n を返す。
sz = size
sz * n if sz
end
end
each do |*val|
n.times { yield *val }
end
end
end
%i[hello world].repeat(2) { |w| puts w }
# => 'hello', 'hello', 'world', 'world'
enum = (1..14).repeat(3)... -
Object
# to _ enum(method = :each , *args) -> Enumerator (32.0) -
Enumerator.new(self, method, *args) を返します。
...# size メソッドが nil でなければ size * n を返す。
sz = size
sz * n if sz
end
end
each do |*val|
n.times { yield *val }
end
end
end
%i[hello world].repeat(2) { |w| puts w }
# => 'hello', 'hello', 'world', 'world'
enum = (1..14).repeat(3)... -
Object
# to _ enum(method = :each , *args) {|*args| . . . } -> Enumerator (32.0) -
Enumerator.new(self, method, *args) を返します。
...# size メソッドが nil でなければ size * n を返す。
sz = size
sz * n if sz
end
end
each do |*val|
n.times { yield *val }
end
end
end
%i[hello world].repeat(2) { |w| puts w }
# => 'hello', 'hello', 'world', 'world'
enum = (1..14).repeat(3)... -
Object
# _ dump(limit) -> String (26.0) -
Marshal.#dump において出力するオブジェクトがメソッド _dump を定義している場合には、そのメソッドの結果が書き出されます。
...ッド _dump
を定義している場合には、そのメソッドの結果が書き出されます。
バージョン1.8.0以降ではObject#marshal_dump, Object#marshal_loadの使用
が推奨されます。 Marshal.dump するオブジェクトが _dump と marshal_dump の両方の
メソッ......べきです。
//emlist[][ruby]{
class Foo
def initialize(arg)
@foo = arg
end
def _dump(limit)
Marshal.dump(@foo, limit)
end
def self._load(obj)
p obj
Foo.new(Marshal.load(obj))
end
end
foo = Foo.new(['foo', 'bar'])
p foo #=> #<Foo:0xbaf234 @foo=["f......い場合や拡張ライブラリで定義し
たクラスのインスタンスがインスタンス変数以外に情報を保持する場合に
利用します。(例えば、クラス Time は、_dump/_load を定義して
います)
@see Object#marshal_dump, Object#marshal_load, Class#_load... -
Object
# define _ singleton _ method(symbol) { . . . } -> Symbol (26.0) -
self に特異メソッド name を定義します。
...表す Symbol を返します。
//emlist[][ruby]{
class A
class << self
def class_name
to_s
end
end
end
A.define_singleton_method(:who_am_i) do
"I am: #{class_name}"
end
A.who_am_i # ==> "I am: A"
guy = "Bob"
guy.define_singleton_method(:hello) { "#{self}: Hello there!" }
gu... -
Object
# define _ singleton _ method(symbol , method) -> Symbol (26.0) -
self に特異メソッド name を定義します。
...表す Symbol を返します。
//emlist[][ruby]{
class A
class << self
def class_name
to_s
end
end
end
A.define_singleton_method(:who_am_i) do
"I am: #{class_name}"
end
A.who_am_i # ==> "I am: A"
guy = "Bob"
guy.define_singleton_method(:hello) { "#{self}: Hello there!" }
gu... -
Object
# initialize(*args , &block) -> object (26.0) -
ユーザ定義クラスのオブジェクト初期化メソッド。
...mlist[][ruby]{
class Foo
def initialize name
puts "initialize Foo"
@name = name
end
end
class Bar < Foo
def initialize name, pass
puts "initialize Bar"
super name
@pass = pass
end
end
it = Bar.new('myname','0500')
p it
#=> initialize Bar
# initialize Foo
# #<Bar:0x2... -
Object
# initialize _ copy(obj) -> object (26.0) -
(拡張ライブラリによる) ユーザ定義クラスのオブジェクトコピーの初期化メソッド。
...elf のインスタンス変数や特異メソッドは変化しません。
デフォルトでは、Object#clone の内部で Object#initialize_clone から、
また Object#dup の内部で Object#initialize_dup から呼ばれます。
initialize_copy は、Ruby インタプリタが知り得......alize_copy でコピーするよう定義しておくことで、dup や clone
を再定義する必要がなくなります。
デフォルトの Object#initialize_copy は、 freeze チェックおよび型のチェックを行い self
を返すだけのメソッドです。
initialize_copy と......Error レシーバが freeze されているか、obj のクラスがレシーバ
のクラスと異なる場合に発生します。
@see Object#clone,Object#dup
以下に例として、dup や clone がこのメソッドをどのように利用しているかを示します。
obj.dup は、...