るりまサーチ

最速Rubyリファレンスマニュアル検索!
444件ヒット [1-100件を表示] (0.036秒)

別のキーワード

  1. rbconfig ruby
  2. fiddle ruby_free
  3. fiddle build_ruby_platform
  4. rake ruby
  5. rubygems/defaults ruby_engine

検索結果

<< 1 2 3 ... > >>

Object#class -> Class (18270.0)

レシーバのクラスを返します。

...レシーバのクラスを返します。

//emlist[][ruby]{
p "ruby".class #=> String
p 100.class #=> Integer
p ARGV.class #=> Array
p self.class #=> Object
p Class.class #=> Class
p Kernel.class #=> Module
//}

@see Class#superclass,Object#kind_of?,Object#instance_of?...

Object#singleton_class -> Class (6246.0)

レシーバの特異クラスを返します。 まだ特異クラスがなければ、新しく作成します。

...れ NilClass, TrueClass,
FalseClass を返します。

@raise TypeError レシーバが Integer、Float、Symbol の場合に発生します。

//emlist[][ruby]{
Object
.new.singleton_class #=> #<Class:#<Object:0xb7ce1e24>>
String.singleton_class #=> #<Class:String>
nil.singleton_class...
...#=> NilClass
//}

@see Object#class...

Object#singleton_methods(inherited_too = true) -> [Symbol] (122.0)

そのオブジェクトに対して定義されている特異メソッド名 (public あるいは protected メソッド) の一覧を返します。

...た特異メソッドとは Object#extend によって追加された特異メソッドや、
self がクラスの場合はスーパークラスのクラスメソッド(Classのインスタンスの特異メソッド)などです。

singleton_methods(false) は、Object#methods(false) と同じで...
...1][ruby]{
Parent = Class.new

class
<<Parent
private; def private_class_parent() end
protected; def protected_class_parent() end
public; def public_class_parent() end
end

Foo = Class.new(Parent)

class
<<Foo
private; def private_class_foo() end
protected; def protected_class_foo()...
...end
public; def public_class_foo() end
end

module Bar
private; def private_bar() end
protected; def protected_bar() end
public; def public_bar() end
end

obj = Foo.new
class
<<obj
include Bar
private; def private_self() end
protected; def protected_self() end
public...

Object#respond_to?(name, include_all = false) -> bool (50.0)

オブジェクトがメソッド name を持つとき真を返します。

...
Ruby
の組み込みライブラリや標準ライブラリなど、C言語で実装されているメソッドのみです。
Ruby
で実装されたメソッドで NotImplementedError が発生する場合は true を返します。

メソッドが定義されていない場合は、Object#resp...
...ます。省略した場合
は false(含めない) を指定した事になります。

//emlist[][ruby]{
class
F
def hello
"Bonjour"
end
end

class
D
private
def hello
"Guten Tag"
end
end
list = [F.new,D.new]

list.each{|it| puts it.hello if it.respond_to?(:he...
...ate_method
raise NotImplementedError.new
end

def finish
puts "finish"
end
end

class
ImplTemplateMethod
include Template
def template_method
"implement template_method"
end
end

class
NotImplTemplateMethod
include Template

# not implement template_method
end

puts ImplT...

Object#===(other) -> bool (44.0)

case 式で使用されるメソッドです。d:spec/control#case も参照してください。

...ルトでは内部で Object#== を呼び出します。

when 節の式をレシーバーとして === を呼び出すことに注意してください。

また Enumerable#grep でも使用されます。

@param other 比較するオブジェクトです。

//emlist[][ruby]{
age = 12
# (0..2).=...
...when /ruby(?!\s*on\s*rails)/i
"hit! #{arg}"
when String
"Instance of String class. But don't hit."
else
"unknown"
end
end

puts check([]) #=> unknown
puts check("mash-up in Ruby on Rails") #=> instance of String class. But not hit...
puts check("<Ruby's world>") #=> hit! <Ruby's wo...
...rld>
//}

@see Object#==, Range#===, Module#===, Regexp#===, Enumerable#grep...

絞り込み条件を変える

Object#initialize(*args, &block) -> object (38.0)

ユーザ定義クラスのオブジェクト初期化メソッド。

...

このメソッドは Class#new から新しく生成されたオブ
ジェクトの初期化のために呼び出されます。他の言語のコンストラクタに相当します。
デフォルトの動作ではなにもしません。

initialize には
Class
#new に与えられた引数...
...@param block 初期化時のブロック引数です。必須ではありません。

//emlist[][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:0x2b68f08 @name="myname", @pass="0500">
//}

@see Class#new...

Object#define_singleton_method(symbol) { ... } -> Symbol (32.0)

self に特異メソッド name を定義します。

...ます。

@return メソッド名を表す 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(:...

Object#define_singleton_method(symbol, method) -> Symbol (32.0)

self に特異メソッド name を定義します。

...ます。

@return メソッド名を表す 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(:...

Object#initialize_copy(obj) -> object (32.0)

(拡張ライブラリによる) ユーザ定義クラスのオブジェクトコピーの初期化メソッド。

...特異メソッドは変化しません。

デフォルトでは、Object#clone の内部で Object#initialize_clone から、
また Object#dup の内部で Object#initialize_dup から呼ばれます。

initialize_copy は、Ruby インタプリタが知り得ない情報をコピーするた...
...alize_copy でコピーするよう定義しておくことで、dup や clone
を再定義する必要がなくなります。

デフォルトの Object#initialize_copy は、 freeze チェックおよび型のチェックを行い self
を返すだけのメソッドです。

initialize_copy と...
...ます。
@see Object#clone,Object#dup

以下に例として、dup や clone がこのメソッドをどのように利用しているかを示します。

obj.dup は、新たに生成したオブジェクトに対して
initialize_copy を呼び

//emlist[][ruby]{
obj2 = obj.class.allocate
obj2....
<< 1 2 3 ... > >>