るりまサーチ

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

別のキーワード

  1. rbconfig ruby
  2. fiddle ruby_free
  3. fiddle build_ruby_platform
  4. rake ruby
  5. rubygems/defaults ruby_engine

ライブラリ

クラス

モジュール

検索結果

<< 1 2 3 > >>

Module#include(*mod) -> self (18334.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 (18279.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 (TypeErr...

Module#<=>(other) -> Integer | nil (6267.0)

self と other の継承関係を比較します。

...self と other の継承関係を比較します。

self と other を比較して、
self が other の子孫であるとき -1、
同一のクラス/モジュールのとき 0、
self が other の先祖であるとき 1
を返します。

継承関係にないクラス同士の比較では
n...
...のクラスやモジュール

//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#include?(mod) -> bool (6250.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
//}...

Object#methods(include_inherited = true) -> [Symbol] (280.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

# あるオブジェク...
...:public_singleton]
[:public_singleton, :public_foo]
[:private_singleton, :private_foo]
[:protected_singleton, :protected_foo]
//}


//emlist[例2][ruby]{
# あるオブジェクトの応答できるメソッドの一覧を得る。
# 自身のクラスの親クラスのインスタンスメソッ...

絞り込み条件を変える

Module#ancestors -> [Class, Module] (238.0)

クラス、モジュールのスーパークラスとインクルードしているモジュール を優先順位順に配列に格納して返します。

...先順位順に配列に格納して返します。

//emlist[例][ruby]{
module Foo
end
class
Bar
include
Foo
end
class
Baz < Bar
p ancestors
p included_modules
p superclass
end
# => [Baz, Bar, Foo, Object, Kernel, BasicObject]
# => [Foo, Kernel]
# => Bar
//}

@see Module#included_modules...

REXML::StreamListener#entitydecl(content) -> () (179.0)

DTDの実体宣言をパースしたときに呼び出されるコールバックメソッドです。

...が異なります。

//emlist[][ruby]{
require 'rexml/parsers/baseparser'
require 'rexml/parsers/streamparser'
require 'rexml/streamlistener'
xml = <<EOS
<
!DOCTYPE root [
<
!ENTITY % YN '"Yes"'>
<
!ENTITY % YN 'Yes'>
<
!ENTITY WhatHeSaid "He said %YN;">
<
!ENTITY open-hatch SYSTEM "http://www.textuali...
.../boilerplate/OpenHatch.xml">
<
!ENTITY open-hatch PUBLIC "-//Textuality//TEXT Standard open-hatch boilerplate//EN" "http://www.textuality.com/boilerplate/OpenHatch.xml">
<
!ENTITY hatch-pic SYSTEM "../grafix/OpenHatch.gif" NDATA gif>
]>
<
root />
EOS

class
Listener
include
REXML::StreamListener
de...
...eSaid", "He said %YN;"]
# >> ["open-hatch", "SYSTEM", "http://www.textuality.com/boilerplate/OpenHatch.xml"]
# >> ["open-hatch", "PUBLIC", "-//Textuality//TEXT Standard open-hatch boilerplate//EN", "http://www.textuality.com/boilerplate/OpenHatch.xml"]
# >> ["hatch-pic", "SYSTEM", "../grafix/OpenHat...

Method#inspect -> String (173.0)

self を読みやすい文字列として返します。

...self を読みやすい文字列として返します。

以下の形式の文字列を返します。

#<Method: klass1(klass2)#method> (形式1)

klass1 は、Method#inspect では、レシーバのクラス名、
UnboundMethod#inspect では、UnboundMethod オブジェクト...
...st[例][ruby]{
module Foo
def foo
"foo"
end
end
class
Bar
include
Foo
def bar
end
end

p Bar.new.method(:foo) # => #<Method: Bar(Foo)#foo>
p Bar.new.method(:bar) # => #<Method: Bar#bar>
//}

klass1 と klass2 が同じ場合は以下の形式になります。
#<Method:...
...klass1#method> (形式2)

特異メソッドに対しては、
#<Method: obj.method> (形式3)
#<Method: klass1(klass2).method> (形式4)
という形式の文字列を返します。二番目の形式では klass1 はレシーバ...
...self を読みやすい文字列として返します。

以下の形式の文字列を返します。

#<Method: klass1(klass2)#method(arg) foo.rb:2> (形式1)

klass1 は、Method#inspect では、レシーバのクラス名、
UnboundMethod#inspect では、UnboundMethod オブジェクト...
...場合には付きません。

//emlist[例][ruby]{
module Foo
def foo
"foo"
end
end
class
Bar
include
Foo
def bar(a, b)
end
end

p Bar.new.method(:foo) # => #<Method: Bar(Foo)#foo() test.rb:2>
p Bar.new.method(:bar) # => #<Method: Bar#bar(a, b) test.rb:8>
//}

klass1...
...と klass2 が同じ場合は以下の形式になります。
#<Method: klass1#method() foo.rb:2> (形式2)

特異メソッドに対しては、
#<Method: obj.method() foo.rb:2> (形式3)
#<Method: klass1(klass2).method() foo.rb:2> (形式4)
という形式の...

Method#to_s -> String (173.0)

self を読みやすい文字列として返します。

...self を読みやすい文字列として返します。

以下の形式の文字列を返します。

#<Method: klass1(klass2)#method> (形式1)

klass1 は、Method#inspect では、レシーバのクラス名、
UnboundMethod#inspect では、UnboundMethod オブジェクト...
...st[例][ruby]{
module Foo
def foo
"foo"
end
end
class
Bar
include
Foo
def bar
end
end

p Bar.new.method(:foo) # => #<Method: Bar(Foo)#foo>
p Bar.new.method(:bar) # => #<Method: Bar#bar>
//}

klass1 と klass2 が同じ場合は以下の形式になります。
#<Method:...
...klass1#method> (形式2)

特異メソッドに対しては、
#<Method: obj.method> (形式3)
#<Method: klass1(klass2).method> (形式4)
という形式の文字列を返します。二番目の形式では klass1 はレシーバ...
...self を読みやすい文字列として返します。

以下の形式の文字列を返します。

#<Method: klass1(klass2)#method(arg) foo.rb:2> (形式1)

klass1 は、Method#inspect では、レシーバのクラス名、
UnboundMethod#inspect では、UnboundMethod オブジェクト...
...場合には付きません。

//emlist[例][ruby]{
module Foo
def foo
"foo"
end
end
class
Bar
include
Foo
def bar(a, b)
end
end

p Bar.new.method(:foo) # => #<Method: Bar(Foo)#foo() test.rb:2>
p Bar.new.method(:bar) # => #<Method: Bar#bar(a, b) test.rb:8>
//}

klass1...
...と klass2 が同じ場合は以下の形式になります。
#<Method: klass1#method() foo.rb:2> (形式2)

特異メソッドに対しては、
#<Method: obj.method() foo.rb:2> (形式3)
#<Method: klass1(klass2).method() foo.rb:2> (形式4)
という形式の...
<< 1 2 3 > >>