407件ヒット
[201-300件を表示]
(0.014秒)
キーワード
- === (11)
-
_ dump (11) -
define
_ singleton _ method (22) - display (11)
- extend (11)
- initialize (11)
-
initialize
_ copy (11) - inspect (11)
-
instance
_ of? (11) -
instance
_ variable _ defined? (11) -
instance
_ variable _ get (11) -
instance
_ variables (11) -
is
_ a? (11) -
kind
_ of? (11) -
marshal
_ dump (11) -
marshal
_ load (11) - methods (11)
-
pretty
_ print (11) -
pretty
_ print _ cycle (11) -
public
_ method (11) -
remove
_ instance _ variable (11) -
respond
_ to? (11) -
respond
_ to _ missing? (11) - send (22)
-
singleton
_ class (11) -
singleton
_ method (11) -
singleton
_ methods (11) -
to
_ ary (11) -
to
_ hash (11) -
to
_ int (11) -
to
_ proc (11) -
to
_ regexp (11) -
to
_ s (11) -
to
_ str (11)
検索結果
先頭5件
-
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... -
Object
# pretty _ print _ cycle(pp) -> () (8.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... -
Object
# public _ method(name) -> Method (8.0) -
オブジェクトの public メソッド name をオブジェクト化した Method オブジェクトを返します。
...vate メソッド名を引数として与えると発生します。
//emlist[][ruby]{
1.public_method(:to_int) #=> #<Method: Integer#to_int>
1.public_method(:p) # method `p' for class `Integer' is private (NameError)
//}
@see Object#method,Object#public_send,Module#public_instance_method... -
Object
# respond _ to _ missing?(symbol , include _ private) -> bool (8.0) -
自身が symbol で表されるメソッドに対し BasicObject#method_missing で反応するつもりならば真を返します。
...れるメソッドに対し
BasicObject#method_missing で反応するつもりならば真を返します。
Object#respond_to? はメソッドが定義されていない場合、
デフォルトでこのメソッドを呼びだし問合せます。
BasicObject#method_missing を override した......ram symbol メソッド名シンボル
@param include_private private method も含めたい場合に true が渡されます
//emlist[例][ruby]{
class Sample
def method_missing(name, *args)
if name =~ /^to_*/
[name, *args] # => [:to_sample, "sample args1", "sample args2"]
return......end
end
def respond_to_missing?(sym, include_private)
(sym =~ /^to_*/) ? true : super
end
end
s = Sample.new
s.to_sample("sample args1", "sample args2")
s.respond_to?(:to_sample) # => true
s.respond_to?(:sample) # => false
//}
@see Object#respond_to?, BasicObject#method_missing...