240件ヒット
[201-240件を表示]
(0.074秒)
ライブラリ
- ビルトイン (240)
キーワード
- === (12)
- class (12)
-
enum
_ for (24) - extend (12)
-
instance
_ variables (12) -
is
_ a? (12) -
kind
_ of? (12) - method (12)
- methods (12)
-
private
_ methods (12) -
protected
_ methods (12) -
public
_ method (12) -
public
_ methods (12) -
remove
_ instance _ variable (12) -
respond
_ to? (12) -
singleton
_ method (12) -
singleton
_ methods (12) -
to
_ enum (24)
検索結果
先頭4件
-
Object
# singleton _ method(name) -> Method (8.0) -
オブジェクトの特異メソッド name をオブジェクト化した Method オブ ジェクトを返します。
...o.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, Kernel.#eval, Object#method... -
Object
# singleton _ methods(inherited _ too = true) -> [Symbol] (8.0) -
そのオブジェクトに対して定義されている特異メソッド名 (public あるいは protected メソッド) の一覧を返します。
...た特異メソッドとは Object#extend によって追加された特異メソッドや、
self がクラスの場合はスーパークラスのクラスメソッド(Classのインスタンスの特異メソッド)などです。
singleton_methods(false) は、Object#methods(false) と同じで......rent)
class <<Foo
private; def private_class_foo() end
protected; def protected_class_foo() end
public; def public_class_foo() end
end
module Bar
private; def private_bar() end
protected; def protected_bar() end
public; def public_bar() end
end
obj = Foo.new
class <<obj......ラスのクラスメソッドも含まれるよう true を指定したが、
# Object のクラスメソッドは一覧から排除している。
p obj.singleton_methods(true)
p Foo.singleton_methods(true) - Object.singleton_methods(true)
#実行結果
[:protected_self, :public_self, :protecte... -
Object
# to _ enum(method = :each , *args) -> Enumerator (8.0) -
Enumerator.new(self, method, *args) を返します。
...array from being modified
a = [1, 2, 3]
p(a.to_enum) #=> #<Enumerator: [1, 2, 3]:each>
//}
//emlist[例(ブロックを指定する場合)][ruby]{
module Enumerable
def repeat(n)
raise ArgumentError, "#{n} is negative!" if n < 0
unless block_given?
# __method__ はここでは :repe... -
Object
# to _ enum(method = :each , *args) {|*args| . . . } -> Enumerator (8.0) -
Enumerator.new(self, method, *args) を返します。
...array from being modified
a = [1, 2, 3]
p(a.to_enum) #=> #<Enumerator: [1, 2, 3]:each>
//}
//emlist[例(ブロックを指定する場合)][ruby]{
module Enumerable
def repeat(n)
raise ArgumentError, "#{n} is negative!" if n < 0
unless block_given?
# __method__ はここでは :repe...