るりまサーチ

最速Rubyリファレンスマニュアル検索!
407件ヒット [201-300件を表示] (0.014秒)

別のキーワード

  1. argf.class lines
  2. argf.class each
  3. argf.class each_line
  4. class new
  5. argf.class gets

検索結果

<< < 1 2 3 4 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...

絞り込み条件を変える

<< < 1 2 3 4 5 > >>