ライブラリ
- ビルトイン (198)
- mkmf (22)
-
rexml
/ streamlistener (11)
クラス
- Method (22)
- Module (115)
- Object (33)
- Range (17)
- UnboundMethod (11)
モジュール
- Kernel (22)
-
REXML
:: StreamListener (11)
キーワード
- <= (11)
- <=> (11)
- ancestors (11)
- bind (11)
-
const
_ source _ location (5) - cover? (17)
- entitydecl (11)
- include? (11)
- inspect (11)
-
is
_ a? (11) -
kind
_ of? (11) -
method
_ defined? (11) - methods (11)
-
private
_ method _ defined? (11) -
protected
_ method _ defined? (11) -
public
_ method _ defined? (11) -
to
_ s (11) -
try
_ cpp (22)
検索結果
先頭5件
-
Module
# include(*mod) -> self (18174.0) -
モジュール mod をインクルードします。
...てしまうような include を行った場合に発生します。
//emlist[例][ruby]{
module M
end
module M2
include M
end
module M
include M2
end
//}
実行結果:
-:3:in `append_features': cyclic include detected (ArgumentError)
from -:3:in `include'
from -:3......。
インクルードは多重継承の代わりに用いられており、 mix-in とも呼びます。
//emlist[例][ruby]{
class C
include FileTest
include Math
end
p C.ancestors
# => [C, Math, FileTest, Object, Kernel]
//}
モジュールの機能追加は、クラスの継承関係の......ッド探索の順序です)。
同じモジュールを二回以上 include すると二回目以降は無視されます。
//emlist[例][ruby]{
module M
end
class C1
include M
end
class C2 < C1
include M # この include は無視される
end
p C2.ancestors # => [C2, C1, M, Object, Ker... -
Module
# <(other) -> bool | nil (18143.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
# include?(mod) -> bool (6126.0) -
self かその親クラス / 親モジュールがモジュール mod を インクルードしていれば true を返します。
...クラス / 親モジュールがモジュール mod を
インクルードしていれば true を返します。
@param mod Module を指定します。
//emlist[例][ruby]{
module M
end
class C1
include M
end
class C2 < C1
end
p C1.include?(M) # => true
p C2.include?(M) # => true
//}... -
Module
# <=>(other) -> Integer | nil (6113.0) -
self と 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 Qux <=> Baz # => nil
p Baz <=> Object.new # => nil
//}... -
Module
# <=(other) -> bool | nil (6107.0) -
比較演算子。self が other の子孫であるか、self と other が 同一クラスである場合、 true を返します。 self が other の先祖である場合、false を返します。
...@see Module#<
//emlist[例][ruby]{
module Foo; end
module Bar
include Foo
end
module Baz
prepend Foo
end
Bar.ancestors # => [Bar, Foo]
Foo <= Bar # => false
Bar <= Foo # => true
Baz.ancestors # => [Foo, Baz]
Foo <= Baz # => false
Baz <= Foo # => true
Foo <= Foo # => true
Foo <= Object # =>... -
Object
# methods(include _ inherited = true) -> [Symbol] (114.0) -
そのオブジェクトに対して呼び出せるメソッド名の一覧を返します。 このメソッドは public メソッドおよび protected メソッドの名前を返します。
...。
@param include_inherited 引数が偽の時は Object#singleton_methods(false) と同じになります。
//emlist[例1][ruby]{
class Parent
private; def private_parent() end
protected; def protected_parent() end
public; def public_parent() end
end
class Foo < Parent
priva......te; def private_foo() end
protected; def protected_foo() end
public; def public_foo() end
end
obj = Foo.new
class <<obj
private; def private_singleton() end
protected; def protected_singleton() end
public; def public_singleton() end
end
# あるオブジェク... -
Range
# cover?(obj) -> bool (79.0) -
obj が範囲内に含まれている時に true を返します。
...します。
Range#include? と異なり <=> メソッドによる演算により範囲内かどうかを判定します。
Range#include? は原則として離散値を扱い、
Range#cover? は連続値を扱います。
(数値については、例外として Range#include? も連続的に扱......ら「begin <= obj <= end」を、
trueなら「begin <= obj < end」を意味します。
@param obj 比較対象のオブジェクトを指定します。
//emlist[数値は連続的に扱われているため、 include? / cover? が同じ結果を返す][ruby]{
(1.1..2.3).include?(1.0) # =>......se
(1.1..2.3).include?(1.1) # => true
(1.1..2.3).include?(1.555) # => true
(1.1..2.3).cover?(1.0) # => false
(1.1..2.3).cover?(1.1) # => true
(1.1..2.3).cover?(1.555) # => true
//}
//emlist[String の例][ruby]{
('b'..'d').include?('d') # => true
('b'..'d').include?('ba') # =>... -
Range
# cover?(range) -> bool (41.0) -
2.6 以降の cover? は、Range#include? や Range#=== と異なり、 引数に Range オブジェクトを指定して比較できます。
...2.6 以降の cover? は、Range#include? や Range#=== と異なり、
引数に Range オブジェクトを指定して比較できます。
引数が Range オブジェクトの場合、引数の範囲が self の範囲に含まれる時に true を返します。
@param range 比較対象の........6) #=> true
//}
「(a..b).cover?(c...d)」のように終端を含まない Range オブジェクトが引数に渡されており、
「a <= c && b < d」を満たし、cが数値ではない(つまり引数の Range の終端を
求めるために succ メソッドの呼び出しが必要な......)場合、パフォーマンスの問題が起きる可能性があります。
//emlist[パフォーマンス上の問題が起きる例][ruby]{
p ('aaaaa'..'zzzzy').cover?('aaaaa'...'zzzzz') # => true
//}
@see Range#include?, Range#===... -
Module
# const _ source _ location(name , inherited = true) -> [String , Integer] (25.0) -
name で指定した定数の定義を含むソースコードのファイル名と行番号を配列で返します。
...します。
@param name Symbol,String で定数の名前を指定します。
@param inherited true を指定するとスーパークラスや include したモジュールで定義された定数が対象にはなります。false を指定した場合 対象にはなりません。
@return ソ......す。
//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')......# => ["test.rb", 7]
p B.const_source_location('C1') # => ["test.rb", 2]
p B.const_source_location('C3', false) # => nil -- include したモジュールは検索しない
p A.const_source_location('C2') # => ["test.rb", 16] -- 最後に定義された位置を返... -
Object
# is _ a?(mod) -> bool (25.0) -
オブジェクトが指定されたクラス mod かそのサブクラスのインスタンスであるとき真を返します。
...ュール mod をインクルードしたクラスかそのサブクラス
のインスタンスである場合にも真を返します。
Module#includeだけではなく、Object#extendやModule#prependに
よってサブクラスのインスタンスになる場合も含みます。
上記のい......ラスやモジュールなど、Moduleかそのサブクラスのインスタンスです。
//emlist[][ruby]{
module M
end
class C < Object
include M
end
class S < C
end
obj = S.new
p obj.is_a?(S) # true
p obj.is_a?(C) # true
p obj.is_a?(Object) # true
p obj.is_a?(M) # true... -
Object
# kind _ of?(mod) -> bool (25.0) -
オブジェクトが指定されたクラス mod かそのサブクラスのインスタンスであるとき真を返します。
...ュール mod をインクルードしたクラスかそのサブクラス
のインスタンスである場合にも真を返します。
Module#includeだけではなく、Object#extendやModule#prependに
よってサブクラスのインスタンスになる場合も含みます。
上記のい......ラスやモジュールなど、Moduleかそのサブクラスのインスタンスです。
//emlist[][ruby]{
module M
end
class C < Object
include M
end
class S < C
end
obj = S.new
p obj.is_a?(S) # true
p obj.is_a?(C) # true
p obj.is_a?(Object) # true
p obj.is_a?(M) # true...