444件ヒット
[201-300件を表示]
(0.082秒)
キーワード
- === (12)
-
_ dump (12) -
define
_ singleton _ method (24) - display (12)
- extend (12)
- initialize (12)
-
initialize
_ copy (12) - inspect (12)
-
instance
_ of? (12) -
instance
_ variable _ defined? (12) -
instance
_ variable _ get (12) -
instance
_ variables (12) -
is
_ a? (12) -
kind
_ of? (12) -
marshal
_ dump (12) -
marshal
_ load (12) - methods (12)
-
pretty
_ print (12) -
pretty
_ print _ cycle (12) -
public
_ method (12) -
remove
_ instance _ variable (12) -
respond
_ to? (12) -
respond
_ to _ missing? (12) - send (24)
-
singleton
_ class (12) -
singleton
_ method (12) -
singleton
_ methods (12) -
to
_ ary (12) -
to
_ hash (12) -
to
_ int (12) -
to
_ proc (12) -
to
_ regexp (12) -
to
_ s (12) -
to
_ str (12)
検索結果
先頭5件
-
Object
# inspect -> String (14.0) -
オブジェクトを人間が読める形式に変換した文字列を返します。
...とインスタンス
変数の名前、値の組を元にした文字列を返します。
//emlist[][ruby]{
class Foo
end
Foo.new.inspect # => "#<Foo:0x0300c868>"
class Bar
def initialize
@bar = 1
end
end
Bar.new.inspect # => "#<Bar:0x0300c868 @bar=1>"
/... -
Object
# remove _ instance _ variable(name) -> object (14.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
# display(out = $ stdout) -> nil (8.0) -
オブジェクトを out に出力します。
...st[][ruby]{
class Object
def display(out = $stdout)
out.write self
nil
end
end
//}
@param out 出力先のIOオブジェクトです。指定しない場合は標準出力に出力されます。
@return nil を返します。
//emlist[][ruby]{
Object.new.display #=> #<Object:0xbb0210>... -
Object
# instance _ variable _ defined?(var) -> bool (8.0) -
インスタンス変数 var が定義されていたら真を返します。
...by]{
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#in......stance_variable_set,Object#instance_variables... -
Object
# instance _ variable _ get(var) -> object | nil (8.0) -
オブジェクトのインスタンス変数の値を取得して返します。
...ist[][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#instance_v... -
Object
# instance _ variables -> [Symbol] (8.0) -
オブジェクトのインスタンス変数名をシンボルの配列として返します。
...列として返します。
//emlist[][ruby]{
obj = Object.new
obj.instance_eval { @foo, @bar = nil }
p obj.instance_variables
#=> [:@foo, :@bar]
//}
@see Object#instance_variable_get, Kernel.#local_variables, Kernel.#global_variables, Module.constants, Module#constants, Module#class_variables... -
Object
# marshal _ dump -> object (8.0) -
Marshal.#dump を制御するメソッドです。
...ump/marshal_load を使うべきです。
@return 任意のオブジェクトで marshal_load の引数に利用できます。
//emlist[][ruby]{
class Foo
def initialize(arg)
@foo = arg
end
def marshal_dump
@foo
end
def marshal_load(obj)
p obj
@foo = obj
end
end
foo =......定義されていてもマーシャルできるようになります
(特異メソッドの情報が自動的に dump されるようになるわけではなく、
marshal_dump/marshal_load によりそれを実現する余地があるということです)。
@see Object#marshal_load, Marshal... -
Object
# marshal _ load(obj) -> object (8.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
# pretty _ print(pp) -> () (8.0) -
PP.pp や Kernel.#pp がオブジェクトの内容を出力するときに 呼ばれるメソッドです。PP オブジェクト pp を引数として呼ばれます。
...p 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, PrettyPrint#break......。
@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#breaka...