るりまサーチ

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

別のキーワード

  1. _builtin include?
  2. socket mcast_include
  3. dbm include?
  4. sdbm include?
  5. gdbm include?

クラス

モジュール

検索結果

<< < ... 3 4 5 6 7 ... > >>

Range#===(obj) -> bool (37.0)

始端と終端の中に obj があるとき、true を返します。 そうでないとき、false を返します。

...n 0...60 then puts "low"
when 60...80 then puts "medium" # => medium
when 80..100 then puts "high"
end
//}

2.5 以前は、単純に Range#include? メソッドを内部で呼んでいました。

しかし、2.6 以降では、(文字列を除いて) Range#cover? と同様の処理をす...
...e'
p (Date.today - 100...Date.today + 100).include?(DateTime.now) #=> false
p (Date.today - 100...Date.today + 100).cover?(DateTime.now) #=> true
p (Date.today - 100...Date.today + 100) === DateTime.now #=> true
# 2.5 以前は、=== は、include? と同じく比較できず false を返...
...//emlist[例][ruby]{
p ('a'..'z').include? 'at' #=> false
p ('a'..'z').cover? 'at' #=> true
p ('a'..'z') === 'at' #=> true
# 2.6 以前は、=== は、include? と同じく比較できず false を返していました。
//}

@see d:spec/control#case
@see Range#include?, Range#cover?...

Range#cover?(range) -> bool (34.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#const_defined?(name, inherit = true) -> bool (31.0)

モジュールに name で指定される名前の定数が定義されている時真 を返します。

...クラスや include したモジュールで定義された定数を検索対象
にするかどうかは第二引数で制御することができます。

@param name String, Symbol で指定される定数名。

@param inherit false を指定するとスーパークラスや include したモ...
...t は include したモジュールの定数に対しても
# true を返す
p Object.const_defined?(:FOO) # => true

module Bar
BAR = 1
end
class Object
include
Bar
end
# ユーザ定義のモジュールに対しても同様
p Object.const_defined?(:BAR) # => true

class Baz
include
Bar...

Module#const_get(name, inherit = true) -> object (31.0)

name で指定される名前の定数の値を取り出します。

...クラスや include したモジュールで
定義された定数は対象にはなりません。

@raise NameError 定数が定義されていないときに発生します。

//emlist[例][ruby]{
module Bar
BAR = 1
end
class Object
include
Bar
end
# Object では include された...
...モジュールに定義された定数を見付ける
p Object.const_get(:BAR) # => 1

class Baz
include
Bar
end
# Object以外でも同様
p Baz.const_get(:BAR) # => 1
# 定義されていない定数
p Baz.const_get(:NOT_DEFINED) #=> raise NameError
# 第二引数に false を指定す...
...ると自分自身に定義された定数から探す
p Baz.const_get(:BAR, false) #=> raise NameError
# 完全修飾名を指定すると include や自分自身へ定義されていない場合でも参照できる
p Class.const_get("Bar::BAR") # => 1
//}...

Object#extend(*modules) -> self (31.0)

引数で指定したモジュールのインスタンスメソッドを self の特異 メソッドとして追加します。

...引数で指定したモジュールのインスタンスメソッドを self の特異
メソッドとして追加します。

Module#include は、クラス(のインスタンス)に機能を追加します
が、extend は、ある特定のオブジェクトだけにモジュールの機能を...
....extend Foo, Bar
p obj.a #=> "ok Foo"
p obj.b #=> "ok Bar"

class Klass
include
Foo
extend Bar
end

p Klass.new.a #=> "ok Foo"
p Klass.b #=> "ok Bar"
//}

extend の機能は、「特異クラスに対する Module#include
と言い替えることもできます。
ただしその場合...
...、フック用のメソッド
が Module#extended ではなく Module#included になるという違いがあります。

//emlist[][ruby]{
# obj.extend Foo, Bar とほぼ同じ
class << obj
include
Foo, Bar
end
//}

@see Module#extend_object,Module#include,Module#extended...

絞り込み条件を変える

Range#===(obj) -> bool (26.0)

obj が範囲内に含まれている時に true を返します。 そうでない場合は、false を返します。

...クトを指定します。

//emlist[例][ruby]{
p ("a" .. "c").include?("b") # => true
p ("a" .. "c").include?("B") # => false
p ("a" .. "c").include?("ba") # => false
p ("a" .. "c").cover?("ba") # => true

p (1 .. 3).include?(1.5) # => true
//}

@see d:spec/control#case
@see Range#cover?...

Range#member?(obj) -> bool (26.0)

obj が範囲内に含まれている時に true を返します。 そうでない場合は、false を返します。

...クトを指定します。

//emlist[例][ruby]{
p ("a" .. "c").include?("b") # => true
p ("a" .. "c").include?("B") # => false
p ("a" .. "c").include?("ba") # => false
p ("a" .. "c").cover?("ba") # => true

p (1 .. 3).include?(1.5) # => true
//}

@see d:spec/control#case
@see Range#cover?...

Range#===(obj) -> bool (25.0)

始端と終端の中に obj があるとき、true を返します。 そうでないとき、false を返します。

...n 0...60 then puts "low"
when 60...80 then puts "medium" # => medium
when 80..100 then puts "high"
end
//}

2.5 以前は、単純に Range#include? メソッドを内部で呼んでいました。

しかし、2.6 以降では、(文字列を除いて) Range#cover? と同様の処理をす...
...e'
p (Date.today - 100...Date.today + 100).include?(DateTime.now) #=> false
p (Date.today - 100...Date.today + 100).cover?(DateTime.now) #=> true
p (Date.today - 100...Date.today + 100) === DateTime.now #=> true
# 2.5 以前は、=== は、include? と同じく比較できず false を返...
...していました。
//}


@see d:spec/control#case
@see Range#include?, Range#cover?...

Module#append_features(module_or_class) -> self (19.0)

モジュール(あるいはクラス)に self の機能を追加します。

...加します。

このメソッドは Module#include の実体であり、
include
を Ruby で書くと以下のように定義できます。

//emlist[例][ruby]{
def include(*modules)
modules.reverse_each do |mod|
# append_features や included はプライベートメソッドなので...
...# 直接 mod.append_features(self) などとは書けない
mod.__send__(:append_features, self)
mod.__send__(:included, self)
end
end
//}

@see Module#included...

Module#const_source_location(name, inherited = true) -> [String, Integer] (19.0)

name で指定した定数の定義を含むソースコードのファイル名と行番号を配列で返します。

...します。

@param name Symbol,String で定数の名前を指定します。
@param inherited true を指定するとスーパークラスや include したモジュールで定義された定数が対象にはなります。false を指定した場合 対象にはなりません。
@return ソ...
...//emlist[例][ruby]{
# test.rb:
class A # line 1
C1 = 1
C2 = 2
end

module M # line 6
C3 = 3
end

class B < A # line 10
include
M
C4 = 4
end

class A # 継続して A を定義する
C2 = 8 # 定数を再定義する
end

p B.const_source_location('C4') # =>...
...# => ["test.rb", 7]
p B.const_source_location('C1') # => ["test.rb", 2]

p B.const_source_location('C3', false) # => nil -- include したモジュールは検索しない

p A.const_source_location('C2') # => ["test.rb", 16] -- 最後に定義された位置を返...

絞り込み条件を変える

Module#ruby2_keywords(method_name, ...) -> nil (17.0)

For the given method names, marks the method as passing keywords through a normal argument splat. This should only be called on methods that accept an argument splat (`*args`) but not explicit keywords or a keyword splat. It marks the method such that if the method is called with keyword arguments, the final hash argument is marked with a special flag such that if it is the final element of a normal argument splat to another method call, and that method call does not include explicit keywords or a keyword splat, the final element is interpreted as keywords. In other words, keywords will be passed through the method to other methods.

...s marked with a special
flag such that if it is the final element of a normal argument splat to
another method call, and that method call does not include explicit
keywords or a keyword splat, the final element is interpreted as
keywords. In other words, keywords will be passed through the method to...

Proc#ruby2_keywords -> proc (17.0)

Marks the proc as passing keywords through a normal argument splat. This should only be called on procs that accept an argument splat (`*args`) but not explicit keywords or a keyword splat. It marks the proc such that if the proc is called with keyword arguments, the final hash argument is marked with a special flag such that if it is the final element of a normal argument splat to another method call, and that method call does not include explicit keywords or a keyword splat, the final element is interpreted as keywords. In other words, keywords will be passed through the proc to other methods.

...s marked with a special flag such that if it is the final
element of a normal argument splat to another method call, and that
method call does not include explicit keywords or a keyword splat, the
final element is interpreted as keywords. In other words, keywords will
be passed through the proc to...

RDoc::Context#initialize_methods_etc -> () (17.0)

追加されたメソッド、属性、alias されたメソッド(メソッド名の対応が取れて いないものを含む)、require されたファイル、include されたファイル、定数 をクリアします。

...追加されたメソッド、属性、alias されたメソッド(メソッド名の対応が取れて
いないものを含む)、require されたファイル、include されたファイル、定数
をクリアします。...
<< < ... 3 4 5 6 7 ... > >>