別のキーワード
種類
- インスタンスメソッド (288)
- 特異メソッド (12)
キーワード
-
alias
_ method (4) - attr (12)
-
attr
_ accessor (4) -
attr
_ reader (4) -
attr
_ writer (4) -
class
_ variables (12) - constants (24)
-
define
_ method (24) -
instance
_ methods (12) -
module
_ function (24) - prepend (12)
- private (36)
-
private
_ instance _ methods (12) - protected (36)
-
protected
_ instance _ methods (12) -
psych
_ yaml _ as (4) - public (36)
-
public
_ instance _ methods (12) -
ruby2
_ keywords (12) -
yaml
_ as (4)
検索結果
先頭5件
-
Module
# psych _ yaml _ as(tag) -> () (6101.0) -
クラスと tag の間を関連付けます。
...を関連付けます。
これによって tag 付けされた YAML ドキュメントを Ruby のオブジェクトに
変換したりその逆をしたりすることができます。
この method は deprecated です。 Object.yaml_tag を
かわりに使ってください。
@param tag... -
Module
# ruby2 _ keywords(method _ name , . . . ) -> nil (6101.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.
...ames, 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 argum......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.
This should only be used for methods that delegate keywords to another
method, and only for backwards compatibility with Ruby versions be......fore
2.7.
This method will probably be removed at some point, as it exists only
for backwards compatibility. As it does not exist in Ruby versions
before 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 w... -
Module
# yaml _ as(tag) -> () (6101.0) -
クラスと tag の間を関連付けます。
...を関連付けます。
これによって tag 付けされた YAML ドキュメントを Ruby のオブジェクトに
変換したりその逆をしたりすることができます。
この method は deprecated です。 Object.yaml_tag を
かわりに使ってください。
@param tag... -
Module
# prepend(*modules) -> self (109.0) -
指定したモジュールを self の継承チェインの先頭に「追加する」ことで self の定数、メソッド、モジュール変数を「上書き」します。
...追加されるため、結果として self で定義されたメソッドは
override されます。
modules で指定したモジュールは後ろから順に処理されるため、
modules の先頭が最も優先されます。
また、継承によってこの「上書き」を処理す......のモジュール/クラスのメソッドを呼び出すことができます。
実際の処理は modules の各要素の prepend_features を後ろから順に呼びだすだけです。
Module#prepend_features が継承チェインの改変を実行し、結果として上のような
処理......とで
prepend の処理を追加/変更できます。
@param modules prepend する Module を指定します
@see Module#prepend_features, Module#prepended
//emlist[例][ruby]{
# super と prepend の組み合わせの例
module X
def foo
puts "X1" # (1x)
super # (2x)
puts "X2" #... -
Module
# alias _ method(new , original) -> Symbol (101.0) -
メソッドの別名を定義します。
...ドの別名を定義します。
//emlist[例][ruby]{
module Kernel
alias_method :hoge, :puts # => :hoge
alias_method "foo", :puts # => :foo
end
//}
alias との違いは以下の通りです。
* メソッド名は String または Symbol で指定します
* グローバル変数の別......。String または Symbol で指定します。
@param original 元のメソッド名。String または Symbol で指定します。
@return 作成したエイリアスのメソッド名を表す Symbol を返します。
@see d:spec/def#alias
//emlist[例][ruby]{
module Kernel
alias_method... -
Module
# attr(*name) -> [Symbol] (101.0) -
インスタンス変数読み取りのためのインスタンスメソッド name を定義します。
...ます。
//emlist[例][ruby]{
class User
attr :name # => [:name]
# 複数の名前を渡すこともできる
attr :id, :age # => [:id, :age]
end
//}
このメソッドで定義されるアクセスメソッドの定義は次の通りです。
//emlist[例][ruby]{
def name
@name
end
//}......義は次の通りです。
//emlist[例][ruby]{
def name=(val)
@name = val
end
//}
第 2 引数 に true か false を指定する方法は非推奨です。
@param name String または Symbol で指定します。
@return 定義されたメソッド名を Symbol の配列で返します。... -
Module
# attr(name , false) -> [Symbol] (101.0) -
インスタンス変数読み取りのためのインスタンスメソッド name を定義します。
...ます。
//emlist[例][ruby]{
class User
attr :name # => [:name]
# 複数の名前を渡すこともできる
attr :id, :age # => [:id, :age]
end
//}
このメソッドで定義されるアクセスメソッドの定義は次の通りです。
//emlist[例][ruby]{
def name
@name
end
//}......義は次の通りです。
//emlist[例][ruby]{
def name=(val)
@name = val
end
//}
第 2 引数 に true か false を指定する方法は非推奨です。
@param name String または Symbol で指定します。
@return 定義されたメソッド名を Symbol の配列で返します。... -
Module
# attr(name , true) -> [Symbol] (101.0) -
インスタンス変数読み取りのためのインスタンスメソッド name を定義します。
...ます。
//emlist[例][ruby]{
class User
attr :name # => [:name]
# 複数の名前を渡すこともできる
attr :id, :age # => [:id, :age]
end
//}
このメソッドで定義されるアクセスメソッドの定義は次の通りです。
//emlist[例][ruby]{
def name
@name
end
//}......義は次の通りです。
//emlist[例][ruby]{
def name=(val)
@name = val
end
//}
第 2 引数 に true か false を指定する方法は非推奨です。
@param name String または Symbol で指定します。
@return 定義されたメソッド名を Symbol の配列で返します。... -
Module
# attr _ accessor(*name) -> [Symbol] (101.0) -
インスタンス変数 name に対する読み取りメソッドと書き込みメソッドの両方を 定義します。
...list[例][ruby]{
class User
attr_accessor :name # => [:name, :name=]
# 複数の名前を渡すこともできる
attr_accessor :id, :age # => [:id, :id=, :age, :age=]
end
//}
このメソッドで定義されるメソッドの定義は以下の通りです。
//emlist[例][ruby]{
def name......@name
end
def name=(val)
@name = val
end
//}
@param name String または Symbol を 1 つ以上指定します。
@return 定義されたメソッド名を Symbol の配列で返します。... -
Module
# attr _ reader(*name) -> [Symbol] (101.0) -
インスタンス変数 name の読み取りメソッドを定義します。
...す。
//emlist[例][ruby]{
class User
attr_reader :name # => [:name]
# 複数の名前を渡すこともできる
attr_reader :id, :age # => [:id, :age]
end
//}
このメソッドで定義されるメソッドの定義は以下の通りです。
//emlist[例][ruby]{
def name
@name
end
//......}
@param name String または Symbol を 1 つ以上指定します。
@return 定義されたメソッド名を Symbol の配列で返します。... -
Module
# attr _ writer(*name) -> [Symbol] (101.0) -
インスタンス変数 name への書き込みメソッド (name=) を定義します。
...。
//emlist[例][ruby]{
class User
attr_writer :name # => [:name=]
# 複数の名前を渡すこともできる
attr_writer :id, :age # => [:id=, :age=]
end
//}
このメソッドで定義されるメソッドの定義は以下の通りです。
//emlist[例][ruby]{
def name=(val)
@name......= val
end
//}
@param name String または Symbol を 1 つ以上指定します。
@return 定義されたメソッド名を Symbol の配列で返します。... -
Module
# class _ variables(inherit = true) -> [Symbol] (101.0) -
クラス/モジュールに定義されているクラス変数の名前の配列を返します。
...数を含みます。
//emlist[例][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, Ke......rnel.#global_variables, Object#instance_variables, Module#constants... -
Module
# constants(inherit = true) -> [Symbol] (101.0) -
そのモジュール(またはクラス)で定義されている定数名の配列を返します。
...@see Module.constants, Kernel.#local_variables, Kernel.#global_variables, Object#instance_variables, Module#class_variables
//emlist[Module.constants と Module#constants の違い][ruby]{
# 出力の簡略化のため起動時の定数一覧を取得して後で差し引く
$clist = Module.const......ない
p Module.constants - $clist # => [:BAR, :Bar, :Foo]
class Baz
# Baz は定数を含まない
p constants # => []
# ネストしたクラスでは、外側のクラスで定義した定数は
# 参照可能なので、BAR は、Module.constant......s には含まれる
# (クラス Baz も Bar の定数なので同様)
p Module.constants - $clist # => [:BAR, :Baz, :Foo, :Bar]
end
end
//}... -
Module
# define _ method(name) { . . . } -> Symbol (101.0) -
インスタンスメソッド name を定義します。
...me メソッド名を String または Symbol を指定します。
@param method Proc、Method あるいは UnboundMethod の
いずれかのインスタンスを指定します。
@return メソッド名を表す Symbol を返します。
@raise TypeError method に同じクラス、サ......ブクラス、モジュール以外のメソッ
ドを指定した場合に発生します。
//emlist[例][ruby]{
class Foo
def foo() p :foo end
define_method(:bar, instance_method(:foo))
end
Foo.new.bar # => :foo
//}... -
Module
# define _ method(name , method) -> Symbol (101.0) -
インスタンスメソッド name を定義します。
...me メソッド名を String または Symbol を指定します。
@param method Proc、Method あるいは UnboundMethod の
いずれかのインスタンスを指定します。
@return メソッド名を表す Symbol を返します。
@raise TypeError method に同じクラス、サ......ブクラス、モジュール以外のメソッ
ドを指定した場合に発生します。
//emlist[例][ruby]{
class Foo
def foo() p :foo end
define_method(:bar, instance_method(:foo))
end
Foo.new.bar # => :foo
//}...