るりまサーチ

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

別のキーワード

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

検索結果

<< < ... 4 5 6 >>

Module#module_function() -> nil (6134.0)

メソッドをモジュール関数にします。

...は、プライベートメソッドであると同時に
モジュールの特異メソッドでもあるようなメソッドです。
例えば Math モジュールのメソッドはすべてモジュール関数です。

単一の引数が与えられた時には与えられた引数をその...
...れた時には配列にまとめて返します。
引数なしの時は nil を返します。

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

=== 注意
module
_function はメソッドに「モジュール関数」という属性をつけるメ
ソッドではなく、プ...
...ジュール関数の別名は定義できません。

//emlist[例][ruby]{
module
M
def foo
p "foo"
end

module
_function :foo
alias bar foo
end


M.foo # => "foo"
M.bar # => undefined method `bar' for Foo:Module (NoMethodError)
//}

このコードでは、モジュール関数 foo...

Module#private() -> nil (6128.0)

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

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

引数なしのときは今後このクラスまたはモジュール定義内で新規に定義さ
れるメソッドを関数形式でだけ呼び出せるように(private)設定します。

引数が与えられた時には引数によって指定...
...ッドを private に
設定します。

可視性については d:spec/def#limit を参照して下さい。

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

@raise NameError 存在し...
...

//emlist[例][ruby]{
class Foo
def foo1() 1 end # デフォルトでは public
private # 可視性を private に変更
def foo2() 2 end # foo2 は private メソッド
end


foo = Foo.new
p foo.foo1 # => 1
p foo.foo2 # => private method `foo2' cal...

Module#class_eval(expr, fname = "(eval)", lineno = 1) -> object (226.0)

モジュールのコンテキストで文字列 expr またはモジュール自身をブロックパラメータとするブロックを 評価してその結果を返します。

...ことです。
つまり、そのモジュールの定義式の中にあるかのように実行されます。

ただし、ローカル変数は module_eval/class_eval の外側のスコープと共有します。

定数とクラス変数のスコープは、文字列が与えられた場合と...
...のスコープはブロックの外側のスコープになります。


@param expr 評価される文字列。

@param fname 文字列を指定します。ファイル fname に文字列 expr が書かれているかのように実行されます。
スタックトレースの表示...
...できます。

//emlist[例][ruby]{
class C
end

a = 1
C.class_eval %Q{
def m # メソッドを動的に定義できる。
return :m, #{a}
end

}

p C.new.m #=> [:m, 1]
//}

//emlist[定数のスコープが異なる例][ruby]{
class C
end


# ブロックが渡され...

Module#module_eval(expr, fname = "(eval)", lineno = 1) -> object (226.0)

モジュールのコンテキストで文字列 expr またはモジュール自身をブロックパラメータとするブロックを 評価してその結果を返します。

...ことです。
つまり、そのモジュールの定義式の中にあるかのように実行されます。

ただし、ローカル変数は module_eval/class_eval の外側のスコープと共有します。

定数とクラス変数のスコープは、文字列が与えられた場合と...
...のスコープはブロックの外側のスコープになります。


@param expr 評価される文字列。

@param fname 文字列を指定します。ファイル fname に文字列 expr が書かれているかのように実行されます。
スタックトレースの表示...
...できます。

//emlist[例][ruby]{
class C
end

a = 1
C.class_eval %Q{
def m # メソッドを動的に定義できる。
return :m, #{a}
end

}

p C.new.m #=> [:m, 1]
//}

//emlist[定数のスコープが異なる例][ruby]{
class C
end


# ブロックが渡され...

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

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

...f#limit を参照して下さい。

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

@raise NameError 存在しないメソッド名を指定した場合に発生します。

//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 bar # => 2
p self.bar # =>...

絞り込み条件を変える

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

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

...クラス変数に設定さ
れていた値を返します。

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

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

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

//emlist[例][ruby]{
class 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 (215.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.

... 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, t...
...ent 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 meth...
...od to
other methods.

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

T
his method will probably be removed at some point, as it exists only
for backwards compatibility. As it does not exist in Ruby ve...
<< < ... 4 5 6 >>