るりまサーチ

最速Rubyリファレンスマニュアル検索!
749件ヒット [601-700件を表示] (0.082秒)
トップページ > クエリ:Ruby[x] > クエリ:ruby[x] > 種類:インスタンスメソッド[x] > クエリ:-[x] > クエリ:@[x] > クラス:Object[x]

別のキーワード

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

ライブラリ

キーワード

検索結果

<< < ... 5 6 7 8 > >>

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

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

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

@
param mod クラスやモジュールなど、Moduleかそ...
...です。

//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#pretty_print(pp) -> () (126.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,...
...ッドを定義しています。

@
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, PrettyP...

Object#pretty_print_cycle(pp) -> () (126.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...

Object#singleton_class -> Class (126.0)

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

...します。

@
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#to_s -> String (126.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#!~(other) -> bool (120.0)

自身が other とマッチしない事を判定します。

...身が other とマッチしない事を判定します。

self#=~(obj) を反転した結果と同じ結果を返します。

@
param other 判定するオブジェクトを指定します。

//emlist[例][ruby]{
obj = 'regexp'
p (obj !~ /re/) # => false

obj = nil
p (obj !~ /re/) # => true
//}...

Object#<=>(other) -> 0 | nil (120.0)

self === other である場合に 0 を返します。そうでない場合には nil を返します。

...self === other である場合に 0 を返します。そうでない場合には nil を返します。

//emlist[例][ruby]{
a = Object.new
b = Object.new
a <=> a # => 0
a <=> b # => nil
//}

@
see Object#===...

Object#frozen? -> bool (120.0)

オブジェクトが凍結(内容の変更を禁止)されているときに真を返します。

...オブジェクトが凍結(内容の変更を禁止)されているときに真を返します。

//emlist[][ruby]{
obj = "someone"
p obj.frozen? #=> false
obj.freeze
p obj.frozen? #=> true
//}

@
see Object#freeze...

Object#tap {|x| ... } -> self (120.0)

self を引数としてブロックを評価し、self を返します。

...目的です。

//emlist[][ruby]{
(1..10) .tap {|x| puts "original: #{x}" }
.to_a .tap {|x| puts "array: #{x}" }
.select {|x| x.even? } .tap {|x| puts "evens: #{x}" }
.map {|x| x*x } .tap {|x| puts "squares: #{x}" }
//}

@
see Object#yield_self...
<< < ... 5 6 7 8 > >>