ライブラリ
クラス
-
ARGF
. class (176) - BasicObject (132)
- Class (44)
- ERB (11)
- Hash (33)
-
JSON
:: Parser (11) - Method (84)
- Module (243)
- NameError (9)
- Object (407)
- OptionParser (132)
- PP (11)
-
RDoc
:: CodeObject (11) -
WIN32OLE
_ TYPE (22) -
WIN32OLE
_ TYPELIB (22)
モジュール
キーワード
- ! (11)
- != (11)
- < (11)
- <=> (11)
- == (11)
- === (18)
- DelegateClass (11)
- [] (11)
-
_ _ send _ _ (22) -
_ dump (11) -
_ load (11) - allocate (11)
- ancestors (11)
- argv (11)
- call (22)
- class (11)
-
class
_ eval (22) -
class
_ exec (11) -
class
_ variable _ get (11) -
class
_ variable _ set (11) -
class
_ variables (11) - clone (11)
-
const
_ defined? (11) -
const
_ source _ location (5) - constants (11)
-
def
_ class (11) -
default
_ event _ sources (11) -
define
_ singleton _ method (22) - display (11)
- dup (11)
- each (44)
-
each
_ byte (22) -
each
_ char (22) -
each
_ line (44) - extend (11)
- getbyte (11)
- getc (11)
- include (11)
- initialize (11)
-
initialize
_ copy (11) - inspect (22)
-
instance
_ eval (22) -
instance
_ exec (11) -
instance
_ method (11) -
instance
_ methods (11) -
instance
_ variable _ defined? (11) -
instance
_ variable _ get (11) -
instance
_ variables (11) -
is
_ a? (11) -
kind
_ of? (11) -
marshal
_ dump (11) -
marshal
_ load (11) - max (44)
-
method
_ missing (11) - methods (11)
- min (44)
-
module
_ eval (22) -
module
_ exec (11) - new (11)
-
object
_ group (11) -
ole
_ classes (11) -
ole
_ type (11) -
ole
_ types (11) - on (132)
- parameters (11)
- parse (11)
-
pretty
_ print (11) -
pretty
_ print _ cycle (11) -
private
_ constant (9) -
public
_ constant (9) -
public
_ method (11) - putc (11)
- receiver (20)
-
remove
_ class _ variable (11) -
remove
_ classes _ and _ modules (11) -
remove
_ const (11) -
remove
_ instance _ variable (11) - replace (11)
-
respond
_ to? (11) -
respond
_ to _ missing? (11) - send (22)
-
singleton
_ class (11) -
singleton
_ method (11) -
singleton
_ method _ added (11) -
singleton
_ method _ removed (11) -
singleton
_ method _ undefined (11) -
singleton
_ methods (11) -
sort
_ by (22) - superclass (11)
- timeout (16)
-
to
_ ary (11) -
to
_ int (11) -
to
_ json (11) -
to
_ json _ raw _ object (11) -
to
_ proc (11) -
to
_ regexp (11) -
to
_ s (22) -
to
_ str (11)
検索結果
先頭5件
-
Object
# marshal _ load(obj) -> object (21114.0) -
Marshal.#load を制御するメソッドです。
...のとき、marshal_dump の返り値が marshal_load の引数に利用されます。
marshal_load 時の self は、生成されたばかり(Class#allocate されたばかり) の状態です。
marshal_dump/marshal_load の仕組みは Ruby 1.8.0 から導入されました。
これから......書くプログラムでは _dump/_load ではなく
marshal_dump/marshal_load を使うべきです。
@param obj marshal_dump の返り値のコピーです。
@return 返り値は無視されます。
@see Object#marshal_dump, Marshal... -
Object
# remove _ instance _ variable(name) -> object (21114.0) -
オブジェクトからインスタンス変数 name を取り除き、そのインス タンス変数に設定されていた値を返します。
...ない場合に発生します。
//emlist[][ruby]{
class Foo
def foo
@foo = 1
p remove_instance_variable(:@foo) #=> 1
p remove_instance_variable(:@foo) # instance variable @foo not defined (NameError)
end
end
Foo.new.foo
//}
@see Module#remove_class_variable,Module#remove_const... -
Object
# methods(include _ inherited = true) -> [Symbol] (21067.0) -
そのオブジェクトに対して呼び出せるメソッド名の一覧を返します。 このメソッドは public メソッドおよび protected メソッドの名前を返します。
...。
ただし特別に、引数が偽の時は Object#singleton_methods(false) と同じになっています。
@param include_inherited 引数が偽の時は Object#singleton_methods(false) と同じになります。
//emlist[例1][ruby]{
class Parent
private; def private_parent() end......; def protected_parent() end
public; def public_parent() end
end
class Foo < Parent
private; def private_foo() end
protected; def protected_foo() end
public; def public_foo() end
end
obj = Foo.new
class <<obj
private; def private_singleton() end
protected; def p......指定して
# いるが、Object のインスタンスメソッドは一覧から排除している。
p obj.methods(true) - Object.instance_methods(true)
p obj.public_methods(true) - Object.public_instance_methods(true)
p obj.private_methods(true) - Object.private_instance_methods(t... -
Object
# is _ a?(mod) -> bool (21049.0) -
オブジェクトが指定されたクラス mod かそのサブクラスのインスタンスであるとき真を返します。
...ードしたクラスかそのサブクラス
のインスタンスである場合にも真を返します。
Module#includeだけではなく、Object#extendやModule#prependに
よってサブクラスのインスタンスになる場合も含みます。
上記のいずれでもない場合に fa......です。
//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 (21049.0) -
オブジェクトが指定されたクラス mod かそのサブクラスのインスタンスであるとき真を返します。
...ードしたクラスかそのサブクラス
のインスタンスである場合にも真を返します。
Module#includeだけではなく、Object#extendやModule#prependに
よってサブクラスのインスタンスになる場合も含みます。
上記のいずれでもない場合に fa......です。
//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
# instance _ of?(klass) -> bool (21043.0) -
オブジェクトがクラス klass の直接のインスタンスである時真を返します。
...obj.instance_of?(c) が成立する時には、常に 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
# _ dump(limit) -> String (21037.0) -
Marshal.#dump において出力するオブジェクトがメソッド _dump を定義している場合には、そのメソッドの結果が書き出されます。
...ッド _dump
を定義している場合には、そのメソッドの結果が書き出されます。
バージョン1.8.0以降ではObject#marshal_dump, Object#marshal_loadの使用
が推奨されます。 Marshal.dump するオブジェクトが _dump と marshal_dump の両方の
メソッ......ベルを表す整数です。
@return オブジェクトを文字列化したものを返すように定義すべきです。
//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(Ma......い場合や拡張ライブラリで定義し
たクラスのインスタンスがインスタンス変数以外に情報を保持する場合に
利用します。(例えば、クラス Time は、_dump/_load を定義して
います)
@see Object#marshal_dump, Object#marshal_load, Class#_load... -
Object
# respond _ to?(name , include _ all = false) -> bool (21031.0) -
オブジェクトがメソッド name を持つとき真を返します。
...されたメソッドで NotImplementedError が発生する場合は true を返します。
メソッドが定義されていない場合は、Object#respond_to_missing? を呼
び出してその結果を返します。
@param name Symbol または文字列で指定するメソッド名です。......す。省略した場合
は 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?(:hello......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
# to _ s -> String (21031.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
# pretty _ print _ cycle(pp) -> () (21029.0) -
プリティプリント時にオブジェクトの循環参照が検出された場合、 Object#pretty_print の代わりに呼ばれるメソッドです。
...た場合、
Object#pretty_print の代わりに呼ばれるメソッドです。
あるクラスの pp の出力をカスタマイズしたい場合は、
このメソッドも再定義する必要があります。
@param pp PP オブジェクトです。
//emlist[][ruby]{
class Array
def pre......tty_print_cycle(q)
q.text(empty? ? '[]' : '[...]')
end
end
//}
@see Object#pretty_print...