るりまサーチ

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

別のキーワード

  1. openssl t61string
  2. asn1 t61string
  3. matrix t
  4. t61string new
  5. fiddle type_size_t

ライブラリ

検索結果

<< < 1 2 3 4 5 > >>

Object#singleton_method(name) -> Method (6132.0)

オブジェクトの特異メソッド name をオブジェクト化した Method オブ ジェクトを返します。

...Method オブ
ジェクトを返します。

@param name メソッド名をSymbol またはStringで指定します。
@raise NameError 定義されていないメソッド名を引数として与えると発生します。

//emlist[][ruby]{
class Demo
def initialize(n)
@iv = n
end

def...
...{@iv}"
end

end


k = Demo.new(99)
def k.hi
"Hi, @iv = #{@iv}"
end

m = k.singleton_method(:hi) # => #<Method: #<Demo:0xf8b0c3c4 @iv=99>.hi>
m.call #=> "Hi, @iv = 99"
m = k.singleton_method(:hello) # => NameError
//}

@see Module#instance_method, Method, BasicObject#__send__, Object#send, Kern...
...el.#eval, Object#method...

Object#to_s -> String (6132.0)

オブジェクトの文字列表現を返します。

...rint や Kernel.#sprintf は文字列以外の
オブジェクトが引数に渡された場合このメソッドを使って文字列に変換し
ます。

//emlist[][ruby]{
class Foo
def initialize num
@num = num
end

end

it = Foo.new(40)

puts it #=> #<Foo:0x2b69110>

class Foo
def to_s...
..."Class:Foo Number:#{@num}"
end

end


puts it #=> Class:Foo Number:40
//}

@see Object#to_str,Kernel.#String...

Object#to_proc -> Proc (6126.0)

オブジェクトの Proc への暗黙の変換が必要なときに内部で呼ばれます。 デフォルトでは定義されていません。

...すが、
このメソッドは実際には Object クラスには定義されていません。
必要に応じてサブクラスで定義すべきものです。

//emlist[][ruby]{
def doing
yield
end


class Foo
def to_proc
Proc.new{p 'ok'}
end

end


it = Foo.new
doing(&it) #=> "ok"
//}...

Object#instance_of?(klass) -> bool (6120.0)

オブジェクトがクラス klass の直接のインスタンスである時真を返します。

...

obj.instance_of?(c) が成立する時には、常に obj.kind_of?(c) も成立します。

@param klass Classかそのサブクラスのインスタンスです。

//emlist[][ruby]{
class C < Object
end

class S < C
end


obj = S.new
p obj.instance_of?(S) # true
p obj.instance_of?(C)...
...# false
//}

@see Object#kind_of?,Object#class...

Object#instance_variable_defined?(var) -> bool (6120.0)

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

...ist[][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,O...
...bject#instance_variable_set,Object#instance_variables...

絞り込み条件を変える

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

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

...mlist[][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...

Object#pretty_print(pp) -> () (6120.0)

PP.pp や Kernel.#pp がオブジェクトの内容を出力するときに 呼ばれるメソッドです。PP オブジェクト pp を引数として呼ばれます。

...します。
そのとき pretty_print メソッドは指定された pp に対して表示したい自身の内容を追加して
いかなければいけません。いくつかの組み込みクラスについて、
pp ライブラリはあらかじめ pretty_print メソッドを定義してい...
...ブジェクトです。

//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#breakable...
...@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#breakable...

Object#pretty_print_cycle(pp) -> () (6120.0)

プリティプリント時にオブジェクトの循環参照が検出された場合、 Object#pretty_print の代わりに呼ばれるメソッドです。

...
Object
#pretty_print の代わりに呼ばれるメソッドです。

あるクラスの pp の出力をカスタマイズしたい場合は、
このメソッドも再定義する必要があります。

@param pp PP オブジェクトです。

//emlist[][ruby]{
class Array
def pretty_print_cy...
...cle(q)
q.text(empty? ? '[]' : '[...]')
end

end

//}

@see Object#pretty_print...

Object#remove_instance_variable(name) -> object (6120.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...
<< < 1 2 3 4 5 > >>