るりまサーチ

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

別のキーワード

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

ライブラリ

クラス

モジュール

キーワード

検索結果

<< < 1 2 3 > >>

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

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

...します。

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

@
param obj 比較対象のオブジェクトを指定します。

//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) # =>...
...st[String の例][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)...

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

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

...て追加された特異メソッドや、
self
がクラスの場合はスーパークラスのクラスメソッド(Classのインスタンスの特異メソッド)などです。

singleton_methods(false) は、Object#methods(false) と同じです。

@
param inherited_too 継承した特異メ...
...ソッドを含める場合は真を、
そうでない場合は偽を指定します。

//emlist[例1][ruby]{
Parent = Class.new

class <<Parent
private; def private_class_parent() end
protected; def protected_class_parent() end
public; def public_class_parent() end...
...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....

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

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

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

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

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

@
raise TypeError 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 <...

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

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

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

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

@
param range 比較対象の Ran...
...ge クラスのインスタンスを指定します。

//emlist[引数が Range の例][ruby]{
(1..5).cover?(2..3) #=> true
(1..5).cover?(0..6) #=> false
(1..5).cover?(1...6) #=> true
//}

「(a..b).cover?(c...d)」のように終端を含まない Range オブジェクトが引数に渡...
...るために succ メソッドの呼び出しが必要な)場合、パフォーマンスの問題が起きる可能性があります。

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

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

TracePoint#defined_class -> Class | module (73.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 は特異クラ
スを返します。また、Kernel.#set_trace_func の 6...
...く元のクラスを返します。

//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 の上記の差分に注意して
ください。

@
see 50864...

絞り込み条件を変える

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

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

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

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

@
param other 比較対象のモジュールやクラス

@
raise T...
...ルではない場合に発生します。

@
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.ancestor...

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

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

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

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

@
param other 比較対象のモジュールやクラス

@
raise T...
...ypeError 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]...

Module#<(other) -> bool | nil (63.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 Ba...

Method#inspect -> String (59.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) #...
...式では klass1 はレシーバ、
klass2 は実際にそのメソッドを定義しているオブジェクトになります。

//emlist[例][ruby]{
# オブジェクトの特異メソッド
obj = ""
class <<obj
def foo
end
end
p obj.method(:foo) # => #<Method: "".foo>

# クラスメ...
...
self
を読みやすい文字列として返します。

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

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

klass1 は、Method#inspect では、レシーバのクラス名、
UnboundMethod#inspect では、UnboundMethod オブジェクト...
...Method#source_location を表します。
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.meth...
...式では klass1 はレシーバ、
klass2 は実際にそのメソッドを定義しているオブジェクトになります。

//emlist[例][ruby]{
# オブジェクトの特異メソッド
obj = ""
class <<obj
def foo
end
end
p obj.method(:foo) # => #<Method: "".foo() foo.rb:4>

# ク...

Method#to_s -> String (59.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) #...
...式では klass1 はレシーバ、
klass2 は実際にそのメソッドを定義しているオブジェクトになります。

//emlist[例][ruby]{
# オブジェクトの特異メソッド
obj = ""
class <<obj
def foo
end
end
p obj.method(:foo) # => #<Method: "".foo>

# クラスメ...
...
self
を読みやすい文字列として返します。

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

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

klass1 は、Method#inspect では、レシーバのクラス名、
UnboundMethod#inspect では、UnboundMethod オブジェクト...
...Method#source_location を表します。
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.meth...
...式では klass1 はレシーバ、
klass2 は実際にそのメソッドを定義しているオブジェクトになります。

//emlist[例][ruby]{
# オブジェクトの特異メソッド
obj = ""
class <<obj
def foo
end
end
p obj.method(:foo) # => #<Method: "".foo() foo.rb:4>

# ク...

絞り込み条件を変える

<< < 1 2 3 > >>