4件ヒット
[1-4件を表示]
(0.431秒)
ライブラリ
- ビルトイン (3)
キーワード
- BasicObject (1)
- Class (1)
- Method (1)
- Options (1)
検索結果
-
BasicObject (18196.0)
-
特殊な用途のために意図的にほとんど何も定義されていないクラスです。 Objectクラスの親にあたります。Ruby 1.9 以降で導入されました。
...クラスから派生すべきです。
真に必要な場合にだけ BasicObject から派生してください。
=== 例
//emlist[例][ruby]{
class Proxy < BasicObject
def initialize(target)
@target = target
end
def method_missing(message, *args)
@target.__send__(message, *args... -
Class (18058.0)
-
クラスのクラスです。
...正確に言えば、個々のクラスはそれぞれメタクラスと呼
ばれる名前のないクラスをクラスとして持っていて、Class はそのメタ
クラスのクラスです。この関係は少し複雑ですが、Ruby を利用するにあたっ
ては特に重要ではあ......すが、それ以外のほとんどの機能は Module から継
承されています。Module のメソッドのうち
* Module#module_function
* Module#extend_object
* Module#append_features
* Module#prepend_features
* Module#refine
は Class では未定義にされています。... -
Method (142.0)
-
Object#method によりオブジェクト化され たメソッドオブジェクトのクラスです。
...、Method は大規模コードに向くと言えます。
既存のメソッドを Method オブジェクト化する。
//emlist[例][ruby]{
class Foo
def foo(arg)
"foo called with arg #{arg}"
end
end
m = Foo.new.method(:foo)
p m # => #<Method: Foo#foo>
p m.call(1) # =......cc>
p pr.call(1) # => "proc called with arg 1"
//}
Method オブジェクトが有用なのは以下のような場合。
//emlist[例][ruby]{
class Foo
def foo() "foo" end
def bar() "bar" end
def baz() "baz" end
end
obj = Foo.new
# 任意のキーとメソッドの関係をハッシュ......(Method オブジェクトはレシーバを保持する)必
要がないなら Object#public_sendを使う方法も有用。
//emlist[例][ruby]{
class Foo
def foo() "foo" end
def bar() "bar" end
def baz() "baz" end
end
# 任意のキーとメソッド(の名前)の関係をハッシュに... -
RDoc
:: Options (40.0) -
rdoc コマンドのオプションを解析するためのクラスです。
...ンは必ず指定
する必要があります。rdoc --help を実行すると追加したオプションの一覧が
確認できます。
例:
class RDoc::Generator::Spellcheck
RDoc::RDoc.add_generator self
def self.setup_options rdoc_options
op = rdoc_options.option_parser...