るりまサーチ

最速Rubyリファレンスマニュアル検索!
480件ヒット [301-400件を表示] (0.054秒)

別のキーワード

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

ライブラリ

検索結果

<< < ... 2 3 4 5 > >>

Object#to_s -> String (38.0)

オブジェクトの文字列表現を返します。

...使って文字列に変換し
ます。

//emlist[][ruby]{
class Foo
def initialize num
@num = num
end

end

it = Foo.new(40)

puts it #=> #<Foo:0x2b69110>

class Foo
def to_s
"Class:Foo Number:#{@num}"
end

end


puts it #=> Class:Foo Number:40
//}

@see Object#to_str,Kernel.#String...

Object#is_a?(mod) -> bool (32.0)

オブジェクトが指定されたクラス mod かそのサブクラスのインスタンスであるとき真を返します。

...クラスかそのサブクラス
のインスタンスである場合にも真を返します。
Module#includeだけではなく、Object#extendやModule#prepend
よってサブクラスのインスタンスになる場合も含みます。
上記のいずれでもない場合に false を返...
...です。

//emlist[][ruby]{
module M
end

class C < Object
include M
end

class S < C
end


obj = S.new
p obj.is_a?(S) # true
p obj.is_a?(C) # true
p obj.is_a?(Object) # true
p obj.is_a?(M) # true
p obj.is_a?(Hash) # false
//}

@see Object#instance_of?,Module#===,Object#class...

Object#kind_of?(mod) -> bool (32.0)

オブジェクトが指定されたクラス mod かそのサブクラスのインスタンスであるとき真を返します。

...クラスかそのサブクラス
のインスタンスである場合にも真を返します。
Module#includeだけではなく、Object#extendやModule#prepend
よってサブクラスのインスタンスになる場合も含みます。
上記のいずれでもない場合に false を返...
...です。

//emlist[][ruby]{
module M
end

class C < Object
include M
end

class S < C
end


obj = S.new
p obj.is_a?(S) # true
p obj.is_a?(C) # true
p obj.is_a?(Object) # true
p obj.is_a?(M) # true
p obj.is_a?(Hash) # false
//}

@see Object#instance_of?,Module#===,Object#class...

Object#to_proc -> Proc (32.0)

オブジェクトの Proc への暗黙の変換が必要なときに内部で呼ばれます。 デフォルトでは定義されていません。

...すが、
このメソッドは実際には Object クラスには定義されていません。
必要に応じてサブクラスで定義すべきものです。

//emlist[][ruby]{
def doing
yield
end


class Foo
def to_proc
Proc.new{p 'ok'}
end

end


it = Foo.new
doing(&it) #=> "ok"
//}...

Object#instance_of?(klass) -> bool (26.0)

オブジェクトがクラス klass の直接のインスタンスである時真を返します。

...常に obj.kind_of?(c) も成立します。

@param klass Classかそのサブクラスのインスタンスです。

//emlist[][ruby]{
class C < Object
end

class S < C
end


obj = S.new
p obj.instance_of?(S) # true
p obj.instance_of?(C) # false
//}

@see Object#kind_of?,Object#class...

絞り込み条件を変える

Object#instance_variable_defined?(var) -> bool (26.0)

インスタンス変数 var が定義されていたら真を返します。

...[ruby]{
class Fred
def initialize(p1, p2)
@a, @b = p1, p2
end

end

fred = Fred.new('cat', 99)
p fred.instance_variable_defined?(:@a) #=> true
p fred.instance_variable_defined?("@b") #=> true
p fred.instance_variable_defined?("@c") #=> false
//}

@see Object#instance_variable_get,Object...
...#instance_variable_set,Object#instance_variables...

Object#instance_variable_get(var) -> object | nil (26.0)

オブジェクトのインスタンス変数の値を取得して返します。

...emlist[][ruby]{
class Foo
def initialize
@foo = 1
end

end


obj = Foo.new
p obj.instance_variable_get("@foo") #=> 1
p obj.instance_variable_get(:@foo) #=> 1
p obj.instance_variable_get(:@bar) #=> nil
//}

@see Object#instance_variable_set,Object#instance_variables,Object#instanc...

Object#pretty_print(pp) -> () (26.0)

PP.pp や Kernel.#pp がオブジェクトの内容を出力するときに 呼ばれるメソッドです。PP オブジェクト pp を引数として呼ばれます。

...@param pp PP オブジェクトです。

//emlist[][ruby]{
require 'pp'

class Array
def pretty_print(q)
q.group(1, '[', ']') {
q.seplist(self) {|v|
q.pp v
}
}
end

end

//}

@see Object#pretty_print_cycle, Object#inspect, PrettyPrint#text, PrettyPrint#group, PrettyP...
...す。

@param pp PP オブジェクトです。

//emlist[][ruby]{
class Array
def pretty_print(q)
q.group(1, '[', ']') {
q.seplist(self) {|v|
q.pp v
}
}
end

end

//}

@see Object#pretty_print_cycle, Object#inspect, PrettyPrint#text, PrettyPrint#group, PrettyPrint#bre...

Object#pretty_print_cycle(pp) -> () (26.0)

プリティプリント時にオブジェクトの循環参照が検出された場合、 Object#pretty_print の代わりに呼ばれるメソッドです。

...された場合、
Object
#pretty_print の代わりに呼ばれるメソッドです。

あるクラスの pp の出力をカスタマイズしたい場合は、
このメソッドも再定義する必要があります。

@param pp PP オブジェクトです。

//emlist[][ruby]{
class Array
d...
...ef pretty_print_cycle(q)
q.text(empty? ? '[]' : '[...]')
end

end

//}

@see Object#pretty_print...
<< < ... 2 3 4 5 > >>