ライブラリ
- ビルトイン (220)
キーワード
- === (11)
- class (11)
-
enum
_ for (22) - extend (11)
-
instance
_ variables (11) -
is
_ a? (11) -
kind
_ of? (11) - method (11)
- methods (11)
-
private
_ methods (11) -
protected
_ methods (11) -
public
_ method (11) -
public
_ methods (11) -
remove
_ instance _ variable (11) -
respond
_ to? (11) -
singleton
_ method (11) -
singleton
_ methods (11) -
to
_ enum (22)
検索結果
先頭5件
-
Object
# enum _ for(method = :each , *args) {|*args| . . . } -> Enumerator (7.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
# method(name) -> Method (7.0) -
オブジェクトのメソッド name をオブジェクト化した Method オブジェクトを返します。
...ror 定義されていないメソッド名を引数として与えると発生します。
//emlist[][ruby]{
me = -365.method(:abs)
p me #=> #<Method: Integer#abs>
p me.call #=> 365
//}
@see Module#instance_method, Method, BasicObject#__send__, Object#send, Kernel.#eval, Object#singleton_method... -
Object
# methods(include _ inherited = true) -> [Symbol] (7.0) -
そのオブジェクトに対して呼び出せるメソッド名の一覧を返します。 このメソッドは public メソッドおよび protected メソッドの名前を返します。
...ected メソッドの名前を返します。
ただし特別に、引数が偽の時は Object#singleton_methods(false) と同じになっています。
@param include_inherited 引数が偽の時は Object#singleton_methods(false) と同じになります。
//emlist[例1][ruby]{
class Parent......指定して
# いるが、Object のインスタンスメソッドは一覧から排除している。
p obj.methods(true) - Object.instance_methods(true)
p obj.public_methods(true) - Object.public_instance_methods(true)
p obj.private_methods(true) - Object.private_instance_methods(t......ublic_singleton, :protected_foo, :public_foo, :protected_parent, :public_parent]
[:public_singleton, :public_foo, :public_parent]
[:private_singleton, :private_foo, :private_parent]
[:protected_singleton, :protected_foo, :protected_parent]
//}
@see Module#instance_methods,Object#singleton_methods... -
Object
# private _ methods(include _ inherited = true) -> [Symbol] (7.0) -
そのオブジェクトが理解できる private メソッド名の一覧を返します。
...が理解できる private メソッド名の一覧を返します。
@param include_inherited 偽となる値を指定すると自身のクラスのスーパークラスで定義されたメソッドを除きます。
@see Module#private_instance_methods,Object#methods,Object#singleton_methods... -
Object
# protected _ methods(include _ inherited = true) -> [Symbol] (7.0) -
そのオブジェクトが理解できる protected メソッド名の一覧を返します。
...解できる protected メソッド名の一覧を返します。
@param include_inherited 偽となる値を指定すると自身のクラスのスーパークラスで定義されたメソッドを除きます。
@see Module#protected_instance_methods,Object#methods,Object#singleton_methods... -
Object
# public _ method(name) -> Method (7.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
# public _ methods(include _ inherited = true) -> [Symbol] (7.0) -
そのオブジェクトが理解できる public メソッド名の一覧を返します。
...が理解できる public メソッド名の一覧を返します。
@param include_inherited 偽となる値を指定すると自身のクラスのスーパークラスで定義されたメソッドを除きます。
@see Module#public_instance_methods,Object#methods,Object#singleton_methods... -
Object
# singleton _ method(name) -> Method (7.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] (7.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 (7.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...