ライブラリ
クラス
- ERB (12)
- Method (24)
- Module (192)
- Object (84)
-
OpenSSL
:: ASN1 :: ObjectId (24) - TracePoint (12)
- UnboundMethod (12)
モジュール
- Enumerable (24)
- ObjectSpace (12)
-
REXML
:: StreamListener (12) - TSort (93)
キーワード
-
1
. 6 . 8から1 . 8 . 0への変更点(まとめ) (12) - < (12)
- <=> (12)
- Closure (12)
- Forwardable (12)
- MonitorMixin (12)
-
Mutex
_ m (12) -
NEWS for Ruby 2
. 1 . 0 (12) -
NEWS for Ruby 2
. 5 . 0 (8) -
NEWS for Ruby 2
. 6 . 0 (7) -
NEWS for Ruby 2
. 7 . 0 (6) -
NEWS for Ruby 3
. 0 . 0 (5) -
NEWS for Ruby 3
. 1 . 0 (4) - Observable (12)
- Ruby用語集 (12)
- Singleton (12)
- ancestors (12)
-
append
_ features (12) - bind (12)
- cgi (12)
-
const
_ defined? (12) -
const
_ get (12) -
const
_ source _ location (12) - constants (12)
-
def
_ module (12) -
defined
_ class (12) - drb (12)
-
drb
/ extservm (12) -
drb
/ gw (12) - e2mmap (6)
-
each
_ entry (24) -
each
_ strongly _ connected _ component (23) -
each
_ strongly _ connected _ component _ from (23) - entitydecl (12)
- extend (12)
- include? (12)
-
include
_ class _ new (12) - included (12)
- inspect (12)
-
irb
/ completion (12) -
is
_ a? (12) -
kind
_ of? (12) -
method
_ defined? (12) - methods (12)
- new (24)
-
prepend
_ features (12) -
private
_ method _ defined? (12) -
protected
_ method _ defined? (12) -
public
_ method _ defined? (12) - rdoc (12)
-
respond
_ to? (12) -
respond
_ to _ missing? (12) -
rexml
/ parsers / sax2parser (12) -
rexml
/ parsers / streamparser (12) -
ruby 1
. 6 feature (12) -
ruby 1
. 8 . 4 feature (12) -
singleton
_ methods (12) -
strongly
_ connected _ components (12) -
to
_ s (12) -
trace
_ object _ allocations (12) - tsort (24)
-
tsort
_ each (23) - クラス/メソッドの定義 (12)
- 変数と定数 (12)
検索結果
先頭5件
-
Module
# include(*mod) -> self (18185.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... -
static VALUE include
_ class _ new(VALUE module , VALUE super) (12200.0) -
super をスーパークラスとして モジュールの「化身」クラスを作成し返します。
super をスーパークラスとして
モジュールの「化身」クラスを作成し返します。 -
TracePoint
# defined _ class -> Class | module (6262.0) -
メソッドを定義したクラスかモジュールを返します。
...ュールを返します。
//emlist[例][ruby]{
class C; def foo; end; end
trace = TracePoint.new(:call) do |tp|
p tp.defined_class # => C
end.enable do
C.new.foo
end
//}
メソッドがモジュールで定義されていた場合も(include に関係なく)モジュー
ルを返します。......//emlist[例][ruby]{
module M; def foo; end; end
class C; include M; end;
trace = TracePoint.new(:call) do |tp|
p tp.defined_class # => M
end.enable do
C.new.foo
end
//}
[注意] 特異メソッドを実行した場合は TracePoint#defined_class は特異クラ
スを返します。また、K......ラメータは特異クラスではなく元のクラスを返します。
//emlist[例][ruby]{
class C; def self.foo; end; end
trace = TracePoint.new(:call) do |tp|
p tp.defined_class # => #<Class:C>
end.enable do
C.foo
end
//}
Kernel.#set_trace_func と TracePoint の上記の差分に注... -
Module
# included(class _ or _ module) -> () (6253.0) -
self が Module#include されたときに対象のクラスまたはモジュー ルを引数にしてインタプリタがこのメソッドを呼び出します。
...f が Module#include されたときに対象のクラスまたはモジュー
ルを引数にしてインタプリタがこのメソッドを呼び出します。
@param class_or_module Module#include を実行したオブジェクト
//emlist[例][ruby]{
module Foo
def self.included(mod)
p......"#{mod} include #{self}"
end
end
class Bar
include Foo
end
# => "Bar include Foo"
//}
@see Module#append_features... -
Module
# include?(mod) -> bool (6131.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
//}... -
1
. 6 . 8から1 . 8 . 0への変更点(まとめ) (438.0) -
1.6.8から1.8.0への変更点(まとめ) * ((<1.6.8から1.8.0への変更点(まとめ)/インタプリタの変更>)) * ((<1.6.8から1.8.0への変更点(まとめ)/追加されたクラス/モジュール>)) * ((<1.6.8から1.8.0への変更点(まとめ)/追加されたメソッド>)) * ((<1.6.8から1.8.0への変更点(まとめ)/追加された定数>)) * ((<1.6.8から1.8.0への変更点(まとめ)/拡張されたクラス/メソッド(互換性のある変更)>)) * ((<1.6.8から1.8.0への変更点(まとめ)/変更されたクラス/メソッド(互換性のない変更)>)) * ((<1.6.8から1.8.0への変更点(まとめ)/文法の変更>)) * ((<1.6.8から1.8.0への変更点(まとめ)/正規表現>)) * ((<1.6.8から1.8.0への変更点(まとめ)/Marshal>)) * ((<1.6.8から1.8.0への変更点(まとめ)/Windows 対応>)) * ((<1.6.8から1.8.0への変更点(まとめ)/廃止された(される予定の)機能>)) * ((<1.6.8から1.8.0への変更点(まとめ)/ライブラリ>)) * ((<1.6.8から1.8.0への変更点(まとめ)/拡張ライブラリAPI>)) * ((<1.6.8から1.8.0への変更点(まとめ)/バグ修正>)) * ((<1.6.8から1.8.0への変更点(まとめ)/サポートプラットフォームの追加>))
...よくわかりません(^^;
class << Object
p [self.id, self]
class << self
p [self.id, self]
end
end
=> ruby 1.6.7 (2002-03-01) [i586-linux]
[537771634, Class]
[537742484, Class]
=> ruby 1.7.3 (2002-09......-05) [i586-linux]
[537771634, #<Class:Object>]
[537771634, #<Class:Object>]
さらに、オブジェクトの特異クラスのスーパークラスの特異クラスと
オブジェクトの特異クラスの特異クラスのスーパークラスは同じなのだそう......スタンスになりました。
=== クラス階層
: ((<File::Constants>))
File::Constants は、File クラスでなく IO クラスが include するように
なりました。((<ruby-dev:20964>))
: ((<UnboundMethod>)) [compat]
UnboundMethod クラスは Method クラスのサブク... -
ruby 1
. 6 feature (294.0) -
ruby 1.6 feature ruby version 1.6 は安定版です。この版での変更はバグ修正がメイン になります。
...module_eval>)) のブロック内で定数やクラス変数のスコープが
変わることはなくなりました。((<ruby-dev:17876>))
class Foo
FOO = 1
@@foo = 1
end
FOO = 2
@@foo = 2
Foo.module_eval { p FOO, @@foo }
=......列を返すようになった
: 2002-03-08 class variable
((<ruby-talk:35122>))
class C
class << self
def test
@@cv = 5
p @@cv
end
end
test
end
=> -:5:in `test': uninitialized class variable @@cv in C (NameError)
fr......18>)), ((<ruby-dev:15684>)),
((<ruby-dev:15757>))
: ((<Module/include>))
モジュールが再帰的に include されないようになりました。
module Foo; end
module Bar; include Foo; end
module Foo; include Bar; end
p Foo.ancestors
=> ruby 1.6.6 (2001-12-26) [i... -
クラス/メソッドの定義 (270.0)
-
クラス/メソッドの定義 * クラス/メソッドの定義: * class * singleton_class * module * method * operator * nest_method * eval_method * singleton_method * class_method * limit * 定義に関する操作: * alias * undef * defined
...:
* class
* singleton_class
* module
* method
* operator
* nest_method
* eval_method
* singleton_method
* class_method
* limit
* 定義に関する操作:
* alias
* undef
* defined
===[a:class] クラス定義
//emlist[例][ruby]{
class Foo < S......uper
def test
# ...
end
# ...
end
//}
文法:
class 識別子 [`<' superclass ]
式..
end
文法:
class 識別子 [`<' superclass ]
式..
[rescue [error_type,..] [=> evar] [then]
式..]..
[else......い。Net を include できるなどのため)
module Net
class HTTP
end
class FTP
end
end
obj = Net::HTTP.new
# あるいは
include Net
obj = HTTP.new
# 以下のような使い方は組み込みのクラスにも見られる
# 利用者は File::Constants を include することで... -
変数と定数 (236.0)
-
変数と定数 * local * instance * class * class_var_scope * global * pseudo * const * prio
...変数と定数
* local
* instance
* class
* class_var_scope
* global
* pseudo
* const
* prio
Ruby の変数と定数の種別は変数名の最初の一文字によって、
ローカル変数、
インスタンス変数、
クラス変数、
グローバル変数、
定数
のい......ら参照できます。初期化されていない
インスタンス変数を参照した時の値はnilです。
===[a:class] クラス変数
//emlist[例][ruby]{
class Foo
@@foo = 1
def bar
puts @@foo
end
end
//}
@@で始まる変数はクラス変数です。クラス変数はク......2
end
class Baz < Bar
p @@foo += 1 # => 3
end
//}
モジュールで定義されたクラス変数(モジュール変数)は、そのモジュールをイ
ンクルードしたクラス間でも共有されます。
//emlist[][ruby]{
module Foo
@@foo = 1
end
class Bar
include Foo...