るりまサーチ

最速Rubyリファレンスマニュアル検索!
481件ヒット [101-200件を表示] (0.117秒)

別のキーワード

  1. _builtin end
  2. ripper end_seen?
  3. _builtin exclude_end?
  4. _builtin end_with?
  5. zlib end

検索結果

<< < 1 2 3 4 ... > >>

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 は、...
<< < 1 2 3 4 ... > >>