るりまサーチ (Ruby 2.1.0)

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

別のキーワード

  1. _builtin new
  2. _builtin inspect
  3. _builtin []
  4. _builtin to_s
  5. _builtin each

ライブラリ

キーワード

検索結果

Class (138040.0)

クラスのクラスです。

...正確に言えば、個々のクラスはそれぞれメタクラスと呼
ばれる名前のないクラスをクラスとして持っていて、Class はそのメタ
クラスのクラスです。この関係は少し複雑ですが、Ruby を利用するにあたっ
ては特に重要ではあ...
...すが、それ以外のほとんどの機能は Module から継
承されています。Module のメソッドのうち

* Module#module_function
* Module#extend_object
* Module#append_features
* Module#prepend_features
* Module#refine

Class では未定義にされています。...

ARGF.class (42004.0)

ARGF を表すクラスです。

ARGF を表すクラスです。

FalseClass (42004.0)

false のクラス。 false は FalseClass クラスの唯一のインスタンスです。 false は nil オブジェクトとともに偽を表し、 その他の全てのオブジェクトは真です。

...false のクラス。
false は FalseClass クラスの唯一のインスタンスです。
false は nil オブジェクトとともに偽を表し、
その他の全てのオブジェクトは真です。...

NilClass (42004.0)

nil のクラス。 nil は NilClass クラスの唯一のインスタンスです。 nil は false オブジェクトとともに偽を表し、 その他の全てのオブジェクトは真です。

...nil のクラス。
nil は NilClass クラスの唯一のインスタンスです。
nil は false オブジェクトとともに偽を表し、
その他の全てのオブジェクトは真です。...

TrueClass (42004.0)

true のクラス。 true は TrueClass クラスの唯一のインスタンスです。 true は真を表す代表のオブジェクトです。

...true のクラス。
true は TrueClass クラスの唯一のインスタンスです。
true は真を表す代表のオブジェクトです。...

絞り込み条件を変える

Method (24058.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

# 任意のキーとメソッド(の名前)の関係をハッシュに...

UnboundMethod (24040.0)

レシーバを持たないメソッドを表すクラスです。 呼び出すためにはレシーバにバインドする必要があります。

...とができます。

//emlist[例: Method クラスの冒頭にある例を UnboundMethod で書くと以下のようになります。][ruby]{
class
Foo
def foo() "foo" end
def bar() "bar" end
def baz() "baz" end
end

# 任意のキーとメソッドの関係をハッシュに保持して...
...mlist[例: 以下はメソッドの再定義を UnboundMethod を使って行う方法です。普通は alias や super を使います。][ruby]{
class
Foo
def foo
p :foo
end
@@orig_foo = instance_method :foo
def foo
p :bar
@@orig_foo.bind(self).call
end
end

Foo.new.foo

# =...

BasicObject (24022.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...

Numeric (24022.0)

数値を表す抽象クラスです。Integer や Float などの数値クラス は Numeric のサブクラスとして実装されています。

...d
//}

また、任意桁の切上げ、切捨て、四捨五入を行うメソッドは以下のように
定義できます。

//emlist[][ruby]{
class
Numeric
def roundup(d=0)
x = 10**d
if self > 0
self.quo(x).ceil * x
else
self.quo(x).floor * x
end
end

def roun...

Thread::Backtrace::Location (24022.0)

Ruby のフレームを表すクラスです。

...例1の実行結果:

caller_locations.rb:2:in `a'
caller_locations.rb:5:in `b'
caller_locations.rb:8:in `c'

//emlist[例2][ruby]{
# foo.rb
class
Foo
attr_accessor :locations
def initialize(skip)
@locations = caller_locations(skip)
end
end

Foo.new(0..2).locations.map do |call|
p...

絞り込み条件を変える