るりまサーチ

最速Rubyリファレンスマニュアル検索!
240件ヒット [101-200件を表示] (0.079秒)

別のキーワード

  1. _builtin end
  2. ripper end_seen?
  3. _builtin exclude_end?
  4. _builtin end_with?
  5. io seek_end

検索結果

<< < 1 2 3 > >>

Module#private_class_method(names) -> self (6150.0)

name で指定したクラスメソッド (クラスの特異メソッド) の 可視性を private に変更します。

...可視性を private に変更します。

@param name 0 個以上の String または Symbol を指定します。
@param names 0 個以上の String または Symbol を Array で指定します。

//emlist[例][ruby]{
module
Foo
def self.foo; end
end


Foo.singleton_class.private_method_defi...
...ned?(:foo) # => false
Foo.private_class_method(:foo) # => Foo
Foo.singleton_class.private_method_defined?(:foo) # => true
//}...

Module#instance_methods(inherited_too = true) -> [Symbol] (110.0)

そのモジュールで定義されている public および protected メソッド名 の一覧を配列で返します。

...[ruby]{
class Foo
private
; def private_foo() end
protected; def protected_foo() end
public; def public_foo() end
end


# あるクラスのインスタンスメソッドの一覧を得る
p Foo.instance_methods(false)
p Foo.public_instance_methods(false)
p Foo.private_instance_methods...
...class Bar < Foo
end

//}

実行結果

[:protected_foo, :public_foo]
[:public_foo]
[:private_foo]
[:protected_foo]

//emlist[例2][ruby]{
class Bar
private
; def private_foo() end
protected; def protected_foo() end
public; def public_foo() end
end


# あるクラ...
..._instance_methods(true)
p Bar.private_instance_methods(true) - Object.private_instance_methods(true)
p Bar.protected_instance_methods(true) - Object.protected_instance_methods(true)
//}

実行結果

[:protected_foo, :public_foo]
[:public_foo]
[:private_foo]
[:protected_foo]...

Module#method_defined?(name, inherit=true) -> bool (80.0)

モジュールにインスタンスメソッド name が定義されており、 かつその可視性が public または protected であるときに true を返します。

...@see Module#public_method_defined?, Module#private_method_defined?, Module#protected_method_defined?

//emlist[例][ruby]{
module
A
def method1() end
def protected_method1() end
protected :protected_method1
end

class B
def method2() end
def private_method2() end
private
:private_met...
...hod2
end
class C < B
include A
def method3() end
end


A.method_defined? :method1 #=> true
C.method_defined? "method1" #=> true
C.method_defined? "method2" #=> true
C.method_defined? "method2", true #=> true
C.method_defined? "method2", false #=> f...
...alse
C.method_defined? "method3" #=> true
C.method_defined? "protected_method1" #=> true
C.method_defined? "method4" #=> false
C.method_defined? "private_method2" #=> false
//}...

Module#public_constant(*name) -> self (50.0)

name で指定した定数の可視性を public に変更します。

...][ruby]{
module
SampleModule
class SampleInnerClass
end


# => 非公開クラスであることを明示するために private にする
private
_constant :SampleInnerClass
end


begin
SampleModule::SampleInnerClass
rescue => e
e # => #<NameError: private constant SampleModule::SampleInne...
...rClass referenced>
end


module
SampleModule
# => 非公開クラスであることは承知で利用するために public にする
public_constant :SampleInnerClass
end


SampleModule::SampleInnerClass # => SampleModule::SampleInnerClass
//}

@see Module#private_constant, Object#untrusted?...
...rClass referenced>
end


module
SampleModule
# => 非公開クラスであることは承知で利用するために public にする
public_constant :SampleInnerClass
end


SampleModule::SampleInnerClass # => SampleModule::SampleInnerClass
//}

@see Module#private_constant...

Module#protected_method_defined?(name, inherit=true) -> bool (44.0)

インスタンスメソッド name がモジュールに定義されており、 しかもその可視性が protected であるときに true を返します。 そうでなければ false を返します。

...対象になります。

@see Module#method_defined?, Module#public_method_defined?, Module#private_method_defined?

//emlist[例][ruby]{
module
A
def method1() end
end

class B
protected
def method2() end
end

class C < B
include A
def method3() end
end


A.method_defined? :method1...

絞り込み条件を変える

Module#public_method_defined?(name, inherit=true) -> bool (44.0)

インスタンスメソッド name がモジュールに定義されており、 しかもその可視性が public であるときに true を返します。 そうでなければ false を返します。

...対象になります。

@see Module#method_defined?, Module#private_method_defined?, Module#protected_method_defined?

//emlist[例][ruby]{
module
A
def method1() end
end

class B
protected
def method2() end
end

class C < B
include A
def method3() end
end


A.method_defined? :method1...

Module#public() -> nil (26.0)

メソッドを public に設定します。

...た場合に発生します。

//emlist[例][ruby]{
def foo() 1 end
p foo # => 1
# the toplevel default is private
p self.foo # => private method `foo' called for #<Object:0x401c83b0> (NoMethodError)

def bar() 2 end
public :bar # visibility changed (all access allowed)
p b...

Module#public(*name) -> Array (26.0)

メソッドを public に設定します。

...た場合に発生します。

//emlist[例][ruby]{
def foo() 1 end
p foo # => 1
# the toplevel default is private
p self.foo # => private method `foo' called for #<Object:0x401c83b0> (NoMethodError)

def bar() 2 end
public :bar # visibility changed (all access allowed)
p b...

Module#public(name) -> String | Symbol (26.0)

メソッドを public に設定します。

...た場合に発生します。

//emlist[例][ruby]{
def foo() 1 end
p foo # => 1
# the toplevel default is private
p self.foo # => private method `foo' called for #<Object:0x401c83b0> (NoMethodError)

def bar() 2 end
public :bar # visibility changed (all access allowed)
p b...
<< < 1 2 3 > >>