るりまサーチ

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

別のキーワード

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

クラス

モジュール

オブジェクト

キーワード

検索結果

<< < 1 2 3 > >>

Enumerable#each_entry {|obj| block} -> self (8109.0)

ブロックを各要素に一度ずつ適用します。

...す。

一要素として複数の値が渡された場合はブロックには配列として渡されます。

//emlist[例][ruby]{
class Foo
include
Enumerable
def each
yield 1
yield 1,2
end
end
Foo.new.each_entry{|o| print o, " -- "}
# => 1 -- [1, 2] --
//}

ブロックを省略...

Range#cover?(obj) -> bool (8071.0)

obj が範囲内に含まれている時に true を返します。

...します。

Range#include? と異なり <=> メソッドによる演算により範囲内かどうかを判定します。
Range#include? は原則として離散値を扱い、
Range#cover? は連続値を扱います。
(数値については、例外として Range#include? も連続的に扱...
...指定します。

//emlist[数値は連続的に扱われているため、 include? / cover? が同じ結果を返す][ruby]{
(1.1..2.3).include?(1.0) # => false
(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?...
...の例][ruby]{
('b'..'d').include?('d') # => true
('b'..'d').include?('ba') # => false
('b'..'d').cover?('d') # => true
('b'..'d').cover?('ba') # => true
//}

//emlist[Date, DateTime の例][ruby]{
require 'date'
(Date.today - 365 .. Date.today + 365).include?(Date.today) #=> true...

Object#singleton_methods(inherited_too = true) -> [Symbol] (8068.0)

そのオブジェクトに対して定義されている特異メソッド名 (public あるいは protected メソッド) の一覧を返します。

...承した特異メソッドを含みます。
継承した特異メソッドとは Object#extend によって追加された特異メソッドや、
self
がクラスの場合はスーパークラスのクラスメソッド(Classのインスタンスの特異メソッド)などです。

singleton_m...
...def protected_bar() end
public; def public_bar() end
end

obj = Foo.new
class <<obj
include
Bar
private; def private_self() end
protected; def protected_self() end
public; def public_self() end
end

# あるオブジェクトの特異メソッドの一覧を得る。
p obj....
...singleton_methods(false)
p obj.methods(false)
p Foo.singleton_methods(false)

#実行結果

[:protected_self, :public_self]
[:protected_self, :public_self]
[:protected_class_foo, :public_class_foo]
//}


//emlist[例2][ruby]{
# あるオブジェクトの特異メソッドの一覧を得る。
#...

Module#<=(other) -> bool | nil (8056.0)

比較演算子。self が other の子孫であるか、self と other が 同一クラスである場合、 true を返します。 self が other の先祖である場合、false を返します。

...比較演算子。self が other の子孫であるか、self と other が
同一クラスである場合、 true を返します。
self
が other の先祖である場合、false を返します。

継承関係にないクラス同士の比較では
nil を返します。

@param other 比較...
...Error other がクラスやモジュールではない場合に発生します。

@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]
Fo...

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

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

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

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

継承関係にないクラス同士の比較では
n...
...ルでなければ
nil を返します。

@param 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 # => n...

絞り込み条件を変える

Range#cover?(range) -> bool (8041.0)

2.6 以降の cover? は、Range#include? や Range#=== と異なり、 引数に Range オブジェクトを指定して比較できます。

...2.6 以降の cover? は、Range#include? や Range#=== と異なり、
引数に Range オブジェクトを指定して比較できます。

引数が Range オブジェクトの場合、引数の範囲が self の範囲に含まれる時に true を返します。

@param range 比較対象の...
...るために succ メソッドの呼び出しが必要な)場合、パフォーマンスの問題が起きる可能性があります。

//emlist[パフォーマンス上の問題が起きる例][ruby]{
p ('aaaaa'..'zzzzy').cover?('aaaaa'...'zzzzz') # => true
//}

@see Range#include?, Range#===...

Module#<(other) -> bool | nil (8040.0)

比較演算子。self が other の子孫である場合、 true を返します。 self が other の先祖か同一のクラス/モジュールである場合、false を返します。

...比較演算子。self が other の子孫である場合、 true を返します。
self
が other の先祖か同一のクラス/モジュールである場合、false を返します。

継承関係にないクラス同士の比較では
nil を返します。

@param other 比較対象のモ...
...

@raise TypeError other がクラスやモジュールではない場合に発生します。

//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...

Module#>(other) -> bool | nil (8040.0)

比較演算子。 self が other の先祖である場合、true を返します。 self が other の子孫か同一クラスである場合、false を返します。

...比較演算子。 self が other の先祖である場合、true を返します。
self
が other の子孫か同一クラスである場合、false を返します。

継承関係にないクラス同士の比較では
nil を返します。

@param other 比較対象のモジュールやクラ...
...ます。

@see Module#<

//emlist[例][ruby]{
module Awesome; end
module Included
include
Awesome
end
module Prepended
prepend Awesome
end

Include
d.ancestors # => [Included, Awesome]
Awesome > Included # => true
Include
d > Awesome # => false

Prepended.ancestors # => [Awesome, Prepended]
Aweso...

Module#>=(other) -> bool | nil (8040.0)

比較演算子。self が other の先祖か同一クラスである場合、 true を返します。 self が other の子孫である場合、false を返します。

...比較演算子。self が other の先祖か同一クラスである場合、 true を返します。
self
が other の子孫である場合、false を返します。

継承関係にないクラス同士の比較では
nil を返します。

@param other 比較対象のモジュールやクラ...
...Error other がクラスやモジュールではない場合に発生します。

@see Module#<

//emlist[例][ruby]{
module Foo; end
module Bar
include
Foo
end
module Baz
prepend Foo
end

Bar.ancestors # => [Bar, Foo]
Foo >= Bar # => true
Bar >= Foo # => false

Baz.ancestors # => [Foo, Baz]
Fo...

Method#inspect -> String (8030.0)

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

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

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

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

klass1 は、Method#inspect では、レシーバのクラス名、
UnboundMethod#inspect では、UnboundMethod オブジェクト...
.../モジュール名、
method は、メソッド名を表します。

//emlist[例][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>
//}

kl...
...# スーパークラスのクラスメソッド
class Bar < Foo
end
p Bar.method(:foo) # => #<Method: Bar.foo>

# 以下は(形式1)の出力になる
module Baz
def baz
end
end

class <<obj
include
Baz
end
p obj.method(:baz) # => #<Method: Object(Baz)#baz>
//}

@see Object#inspect...
...
self
を読みやすい文字列として返します。

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

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

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

//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:...
...ラスメソッド
class Bar < Foo
end
p Bar.method(:foo) # => #<Method: Bar(Foo).foo() foo.rb:11>

# 以下は(形式1)の出力になる
module Baz
def baz
end
end

class <<obj
include
Baz
end
p obj.method(:baz) # => #<Method: String(Baz)#baz() foo.rb:23>
//}

@see Object#inspect...

絞り込み条件を変える

Method#to_s -> String (8030.0)

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

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

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

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

klass1 は、Method#inspect では、レシーバのクラス名、
UnboundMethod#inspect では、UnboundMethod オブジェクト...
.../モジュール名、
method は、メソッド名を表します。

//emlist[例][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>
//}

kl...
...# スーパークラスのクラスメソッド
class Bar < Foo
end
p Bar.method(:foo) # => #<Method: Bar.foo>

# 以下は(形式1)の出力になる
module Baz
def baz
end
end

class <<obj
include
Baz
end
p obj.method(:baz) # => #<Method: Object(Baz)#baz>
//}

@see Object#inspect...
...
self
を読みやすい文字列として返します。

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

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

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

//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:...
...ラスメソッド
class Bar < Foo
end
p Bar.method(:foo) # => #<Method: Bar(Foo).foo() foo.rb:11>

# 以下は(形式1)の出力になる
module Baz
def baz
end
end

class <<obj
include
Baz
end
p obj.method(:baz) # => #<Method: String(Baz)#baz() foo.rb:23>
//}

@see Object#inspect...
<< < 1 2 3 > >>