るりまサーチ

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

別のキーワード

  1. string b
  2. _builtin b
  3. b string
  4. b _builtin

検索結果

<< < 1 2 3 4 ... > >>

Module#class_variable_set(name, val) -> object (6102.0)

クラス/モジュールにクラス変数 name を定義して、その値として val をセットします。val を返します。

...al をセットします。val を返します。

@param name String または Symbol を指定します。

//emlist[例][ruby]{
class Fred
@@foo = 99
def foo
@@foo
end
end

def Fred.foo(val)
class_variable_set(:@@foo, val)
end

p Fred.foo(101) # => 101
p Fred.new.foo # => 101
//}...

Module#class_variables(inherit = true) -> [Symbol] (6102.0)

クラス/モジュールに定義されているクラス変数の名前の配列を返します。

...例][ruby]{
class One
@@var1 = 1
end
class Two < One
@@var2 = 2
end
One.class_variables # => [:@@var1]
Two.class_variables # => [:@@var2, :@@var1]
Two.class_variables(false) # => [:@@var2]
//}

@see Module.constants, Kernel.#local_variables, Kernel.#global_variables, Object#i...
...nstance_variables, Module#constants...

Module#public_class_method(*name) -> self (6102.0)

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

...ラスの特異メソッド) の
可視性を public に変更します。

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

//emlist[例][ruby]{
class Foo
def self.foo
"foo"
end...
...private_class_method :foo
end

Foo.foo # NoMethodError: private method `foo' called for Foo:Class

Foo.public_class_method(:foo) # => Foo
Foo.foo # => "foo"
//}...

Module#public_class_method(names) -> self (6102.0)

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

...ラスの特異メソッド) の
可視性を public に変更します。

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

//emlist[例][ruby]{
class Foo
def self.foo
"foo"
end...
...private_class_method :foo
end

Foo.foo # NoMethodError: private method `foo' called for Foo:Class

Foo.public_class_method(:foo) # => Foo
Foo.foo # => "foo"
//}...

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

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

...定数の可視性を public に変更します。

@param name 0 個以上の String か Symbol を指定します。

@raise NameError 存在しない定数を指定した場合に発生します。

@return self を返します。

//emlist[例][ruby]{
module
SampleModule
class SampleInnerClass...
...:SampleInnerClass
end

b
egin
SampleModule::SampleInnerClass
rescue => e
e # => #<NameError: private constant SampleModule::SampleInnerClass referenced>
end

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

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

@see Module#private_constant, Object#untrusted?...
...nerClass
end

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

@see Module#private_constant...

絞り込み条件を変える

Module#public_instance_method(name) -> UnboundMethod (6102.0)

self の public インスタンスメソッド name をオブジェクト化した UnboundMethod を返します。

...self の public インスタンスメソッド name をオブジェクト化した UnboundMethod を返します。

@param name メソッド名を Symbol または String で指定します。

@raise NameError 定義されていないメソッド名や、
protected メソッド名、 priva...
...として与えると発生します。

//emlist[例][ruby]{
Kernel.public_instance_method(:object_id) #=> #<UnboundMethod: Kernel#object_id>
Kernel.public_instance_method(:p) # method `p' for module `Kernel' is private (NameError)
//}

@see Module#instance_method,Object#public_method...

Module#public_instance_methods(inherited_too = true) -> [Symbol] (6102.0)

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

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

@param inherited_too false を指定するとそのモジュールで定義されているメソッドのみ返します。


@see Object#public_methods, Module#instance_methods...

Module#remove_class_variable(name) -> object (6102.0)

引数で指定したクラス変数を取り除き、そのクラス変数に設定さ れていた値を返します。

...は Symbol を指定します。

@return 引数で指定されたクラス変数に設定されていた値を返します。

@raise NameError 引数で指定されたクラス変数がそのモジュールやクラスに定義されていない場合に発生します。

//emlist[例][ruby]{
cla...
...ss Foo
@@foo = 1
remove_class_variable(:@@foo) # => 1
p @@foo # => uninitialized class variable @@foo in Foo (NameError)
end
//}

@see Module#remove_const, Object#remove_instance_variable...

Module#ruby2_keywords(method_name, ...) -> nil (6102.0)

For the given method names, marks the method as passing keywords through a normal argument splat. This should only be called on methods that accept an argument splat (`*args`) but not explicit keywords or a keyword splat. It marks the method such that if the method is called with keyword arguments, the final hash argument is marked with a special flag such that if it is the final element of a normal argument splat to another method call, and that method call does not include explicit keywords or a keyword splat, the final element is interpreted as keywords. In other words, keywords will be passed through the method to other methods.

...For the given method names, marks the method as passing keywords through
a normal argument splat. This should only be called on methods that
accept an argument splat (`*args`) but not explicit keywords or a
keyword splat. It marks the method such that if the method is called
with keyword argument...
...s will be passed through the method to
other methods.

This should only be used for methods that delegate keywords to another
method, and only for backwards compatibility with Ruby versions before
2.7.

This method will probably be removed at some point, as it exists only
for backwards compatibility...
...exist in Ruby versions
b
efore 2.7, check that the module responds to this method before calling
it. Also, be aware that if this method is removed, the behavior of the
method will change so that it does not pass through keywords.

//emlist[例][ruby]{
module
Mod
def foo(meth, *args, &block)
se...
<< < 1 2 3 4 ... > >>