975件ヒット
[301-400件を表示]
(0.107秒)
別のキーワード
ライブラリ
- ビルトイン (975)
キーワード
- < (12)
- <= (12)
- <=> (12)
- === (12)
- > (12)
- >= (12)
-
alias
_ method (12) - ancestors (12)
-
append
_ features (12) - attr (36)
-
attr
_ accessor (12) -
attr
_ reader (12) -
attr
_ writer (12) - autoload (12)
-
class
_ eval (24) -
class
_ exec (12) -
class
_ variable _ defined? (12) -
class
_ variable _ get (12) -
class
_ variable _ set (12) -
class
_ variables (12) -
const
_ added (3) -
const
_ defined? (12) -
const
_ get (12) -
const
_ missing (12) -
const
_ set (12) -
const
_ source _ location (12) - constants (12)
-
define
_ method (24) -
extend
_ object (12) - extended (12)
- freeze (12)
- include (12)
- include? (12)
- included (12)
-
included
_ modules (12) - inspect (12)
-
instance
_ method (12) -
instance
_ methods (12) -
method
_ added (12) -
method
_ defined? (12) -
method
_ removed (12) -
method
_ undefined (12) -
module
_ eval (24) -
module
_ exec (12) -
module
_ function (36) - name (12)
- prepend (12)
-
prepend
_ features (12) - prepended (12)
- private (48)
-
private
_ class _ method (24) -
private
_ constant (12) -
private
_ instance _ methods (12) -
private
_ method _ defined? (12) -
protected
_ method _ defined? (12) - public (48)
-
public
_ class _ method (24) -
public
_ constant (12) -
public
_ method _ defined? (12) - refine (12)
-
remove
_ class _ variable (12) -
remove
_ const (12) -
remove
_ method (12) -
ruby2
_ keywords (12) -
singleton
_ class? (12) -
to
_ s (12) -
undef
_ method (12)
検索結果
先頭5件
-
Module
# module _ function(name) -> String | Symbol (38.0) -
メソッドをモジュール関数にします。
...て返します。
引数なしの時は 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......付けるには、
以下のように、先に別名を定義してから
それぞれをモジュール関数にしなければいけません。
//emlist[例][ruby]{
module M
def foo
p "foo"
end
alias bar foo
module_function :foo, :bar
end
M.foo # => "foo"
M.bar # => "foo"
//}... -
Module
# const _ missing(name) (36.0) -
定義されていない定数を参照したときに Ruby インタプリタが このメソッドを呼びます。
...い定数を参照したときに Ruby インタプリタが
このメソッドを呼びます。
@param name 参照した定数名の Symbol
@raise NameError このメソッドを呼び出した場合、デフォルトで発生する例外
//emlist[例][ruby]{
class Foo
def Foo.const_missing(......id)
warn "undefined constant #{id.inspect}"
end
Bar
end
Foo::Bar
# => undefined constant :Bar
# undefined constant :Bar
//}... -
Module
# <(other) -> bool | nil (32.0) -
比較演算子。self が other の子孫である場合、 true を返します。 self が other の先祖か同一のクラス/モジュールである場合、false を返します。
.../emlist[例][ruby]{
module Foo
end
class Bar
include Foo
end
class Baz < Bar
end
class Qux
end
p Bar < Foo # => true
p Baz < Bar # => true
p Baz < Foo # => true
p Baz < Qux # => nil
p Baz > Qux # => nil
p Foo < Object.new # => in `<': compared with non class/module (TypeError)... -
Module
# <=>(other) -> Integer | nil (32.0) -
self と other の継承関係を比較します。
...なければ
nil を返します。
@param other 比較対象のクラスやモジュール
//emlist[例][ruby]{
module Foo
end
class Bar
include Foo
end
class Baz < Bar
end
class Qux
end
p Bar <=> Foo # => -1
p Baz <=> Bar # => -1
p Baz <=> Foo # => -1
p Baz <=> Qux # => nil
p Q... -
Module
# attr _ accessor(*name) -> [Symbol] (32.0) -
インスタンス変数 name に対する読み取りメソッドと書き込みメソッドの両方を 定義します。
...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
# const _ defined?(name , inherit = true) -> bool (32.0) -
モジュールに name で指定される名前の定数が定義されている時真 を返します。
...にはなりません。
//emlist[例][ruby]{
module Kernel
FOO = 1
end
# Object は include したモジュールの定数に対しても
# true を返す
p Object.const_defined?(:FOO) # => true
module Bar
BAR = 1
end
class Object
include Bar
end
# ユーザ定義のモジュールに対......しても同様
p Object.const_defined?(:BAR) # => true
class Baz
include Bar
end
# Object 以外でも同様になった
# 第二引数のデフォルト値が true であるため
p Baz.const_defined?(:BAR) # => true
# 第二引数を false にした場合
p Baz.const_defined?(:BAR, fal... -
Module
# const _ source _ location(name , inherited = true) -> [String , Integer] (32.0) -
name で指定した定数の定義を含むソースコードのファイル名と行番号を配列で返します。
...返します。
//emlist[例][ruby]{
# test.rb:
class A # line 1
C1 = 1
C2 = 2
end
module M # line 6
C3 = 3
end
class B < A # line 10
include M
C4 = 4
end
class A # 継続して A を定義する
C2 = 8 # 定数を再定義する
end
p B.const_source_location('C4'......] -- Object を継承している為
p M.const_source_location('A') # => ["test.rb", 1] -- Object は継承していないが追加で modules をチェックする
p Object.const_source_location('A::C1') # => ["test.rb", 2] -- ネストの指定もサポートしている
p Object.... -
Module
# method _ undefined(name) -> () (32.0) -
このモジュールのインスタンスメソッド name が Module#undef_method によって削除されるか、 undef 文により未定義にされると、インタプリタがこのメソッドを呼び出します。
...このモジュールのインスタンスメソッド name が
Module#undef_method によって削除されるか、
undef 文により未定義にされると、インタプリタがこのメソッドを呼び出します。
特異メソッドの削除をフックするには
BasicObject#singlet......たメソッド名が Symbol で渡されます。
//emlist[例][ruby]{
class C
def C.method_undefined(name)
puts "method C\##{name} was undefined"
end
def foo
end
def bar
end
undef_method :foo
undef bar
end
//}
実行結果:
method C#foo was undefined
method C#bar was u... -
Module
# public _ constant(*name) -> self (32.0) -
name で指定した定数の可視性を public に変更します。
...t[例][ruby]{
module SampleModule
class SampleInnerClass
end
# => 非公開クラスであることを明示するために private にする
private_constant :SampleInnerClass
end
begin
SampleModule::SampleInnerClass
rescue => e
e # => #<NameError: private constant SampleModule::Sampl......eInnerClass referenced>
end
module SampleModule
# => 非公開クラスであることは承知で利用するために public にする
public_constant :SampleInnerClass
end
SampleModule::SampleInnerClass # => SampleModule::SampleInnerClass
//}
@see Module#private_constant, Object#untrusted?......eInnerClass referenced>
end
module SampleModule
# => 非公開クラスであることは承知で利用するために public にする
public_constant :SampleInnerClass
end
SampleModule::SampleInnerClass # => SampleModule::SampleInnerClass
//}
@see Module#private_constant...