るりまサーチ

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

別のキーワード

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

検索結果

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