るりまサーチ

最速Rubyリファレンスマニュアル検索!
619件ヒット [1-100件を表示] (0.164秒)

別のキーワード

  1. _builtin to_r
  2. open3 pipeline_r
  3. matrix elements_to_r
  4. fileutils rm_r
  5. fileutils cp_r

検索結果

<< 1 2 3 ... > >>

Object#private_methods(include_inherited = true) -> [Symbol] (6214.0)

そのオブジェクトが理解できる private メソッド名の一覧を返します。

...が理解できる private メソッド名の一覧を返します。

@
param include_inherited 偽となる値を指定すると自身のクラスのスーパークラスで定義されたメソッドを除きます。


@
see Module#private_instance_methods,Object#methods,Object#singleton_methods...

Object#marshal_dump -> object (6144.0)

Marshal.#dump を制御するメソッドです。

...Marshal.#dump を制御するメソッドです。

Marshal.dump(some) において、出力するオブジェクト some がメソッド marshal_dump を
持つ場合には、その返り値がダンプされたものが Marshal.dump(some) の返り値となります。

marshal_dump/marshal_load...
... Ruby 1.8.0 から導入されました。
これから書くプログラムでは _dump/_load ではなく
marshal_dump/marshal_load を使うべきです。

@
return 任意のオブジェクトで marshal_load の引数に利用できます。

//emlist[][ruby]{
class Foo
def initialize(arg)...
...arg
end
def marshal_dump
@
foo
end
def marshal_load(obj)
p obj
@
foo = obj
end
end
foo = Foo.new(['foo', 'bar'])
p foo #=> #<Foo:0xbaf3b0 @foo=["foo", "bar"]>
dms = Marshal.dump(foo)
p dms #=> "\004\bU:\bFoo[\a\"\bfoo\"\bbar"
r
esult = Mar...

Object#remove_instance_variable(name) -> object (6132.0)

オブジェクトからインスタンス変数 name を取り除き、そのインス タンス変数に設定されていた値を返します。

...

@
param name 削除するインスタンス変数の名前をシンボルか文字列で指定します。
@
raise NameError オブジェクトがインスタンス変数 name を持たない場合に発生します。

//emlist[][ruby]{
class Foo
def foo
@
foo = 1
p remove_instance_variabl...
...e(:@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#instance_variable_defined?(var) -> bool (6126.0)

インスタンス変数 var が定義されていたら真を返します。

...var が定義されていたら真を返します。

@
param var インスタンス変数名を文字列か Symbol で指定します。

//emlist[][ruby]{
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#instance_variable_set,Object#instance_variables...

Object#instance_variable_set(var, value) -> object (6126.0)

オブジェクトのインスタンス変数 var に値 value を設定します。

...var に値 value を設定します。

インスタンス変数が定義されていなければ新たに定義されます。

@
param var インスタンス変数名を文字列か Symbol で指定します。
@
param value 設定する値です。
@
return value を返します。

//emlist[][ruby...
...]{
obj = Object.new
p obj.instance_variable_set("@foo", 1) #=> 1
p obj.instance_variable_set(:@foo, 2) #=> 2
p obj.instance_variable_get(:@foo) #=> 2
//}

@
see Object#instance_variable_get,Object#instance_variables,Object#instance_variable_defined?...

絞り込み条件を変える

Object#enum_for(method = :each, *args) -> Enumerator (6120.0)

Enumerator.new(self, method, *args) を返します。

...Enumerator.new(self, method, *args) を返します。

ブロックを指定した場合は Enumerator#size がブロックの評価結果を返
します。ブロックパラメータは引数 args です。


@
param method メソッド名の文字列かシンボルです。
@
param args 呼び出...
...][ruby]{
str = "xyz"

enum = str.enum_for(:each_byte)
p(a = enum.map{|b| '%02x' % b }) #=> ["78", "79", "7a"]

# protects an array from being modified
a = [1, 2, 3]
p(a.to_enum) #=> #<Enumerator: [1, 2, 3]:each>
//}

//emlist[例(ブロックを指定する場合)][ruby]{
module Enumerable
def rep...
...eat(n)
r
aise ArgumentError, "#{n} is negative!" if n < 0
unless block_given?
# __method__ はここでは :repeat
r
eturn to_enum(__method__, n) do
# size メソッドが nil でなければ size * n を返す。
sz = size
sz * n if sz
end
end...

Object#enum_for(method = :each, *args) {|*args| ... } -> Enumerator (6120.0)

Enumerator.new(self, method, *args) を返します。

...Enumerator.new(self, method, *args) を返します。

ブロックを指定した場合は Enumerator#size がブロックの評価結果を返
します。ブロックパラメータは引数 args です。


@
param method メソッド名の文字列かシンボルです。
@
param args 呼び出...
...][ruby]{
str = "xyz"

enum = str.enum_for(:each_byte)
p(a = enum.map{|b| '%02x' % b }) #=> ["78", "79", "7a"]

# protects an array from being modified
a = [1, 2, 3]
p(a.to_enum) #=> #<Enumerator: [1, 2, 3]:each>
//}

//emlist[例(ブロックを指定する場合)][ruby]{
module Enumerable
def rep...
...eat(n)
r
aise ArgumentError, "#{n} is negative!" if n < 0
unless block_given?
# __method__ はここでは :repeat
r
eturn to_enum(__method__, n) do
# size メソッドが nil でなければ size * n を返す。
sz = size
sz * n if sz
end
end...

Object#instance_variable_get(var) -> object | nil (6120.0)

オブジェクトのインスタンス変数の値を取得して返します。

...

@
param var インスタンス変数名を文字列か Symbol で指定します。

//emlist[][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_variable_defined?...

Object#instance_variables -> [Symbol] (6120.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...
<< 1 2 3 ... > >>