ライブラリ
- ビルトイン (1894)
- erb (12)
-
fiddle
/ import (84) -
irb
/ context (12) -
minitest
/ spec (1) -
minitest
/ unit (1) -
mutex
_ m (24) - objspace (12)
- profiler (6)
- psych (8)
- rake (12)
-
rdoc
/ code _ object (12) -
rdoc
/ context (84) -
rdoc
/ stats (12) -
rdoc
/ top _ level (48) - win32ole (36)
クラス
- BasicObject (72)
- Class (24)
- ERB (12)
-
Enumerator
:: Lazy (60) - Hash (6)
-
IRB
:: Context (12) - Method (36)
- Module (1164)
- Object (240)
- Proc (18)
-
RDoc
:: CodeObject (12) -
RDoc
:: Context (84) -
RDoc
:: Stats (12) -
RDoc
:: TopLevel (48) - Refinement (4)
- SystemCallError (12)
- TracePoint (12)
- UnboundMethod (24)
- WIN32OLE (12)
-
WIN32OLE
_ TYPE (24)
モジュール
- Enumerable (48)
-
Fiddle
:: Importer (84) - Kernel (60)
- Marshal (24)
-
MiniTest
:: Assertions (1) -
Mutex
_ m (24) - ObjectSpace (12)
- Warning (9)
オブジェクト
- main (102)
キーワード
-
1
. 6 . 8から1 . 8 . 0への変更点(まとめ) (12) - < (12)
- <= (12)
- <=> (12)
- === (36)
- >= (12)
- Marshal フォーマット (12)
-
NEWS for Ruby 2
. 4 . 0 (9) -
NEWS for Ruby 2
. 5 . 0 (8) -
NEWS for Ruby 3
. 0 . 0 (5) -
Profiler
_ _ (6) - Ruby プログラムの実行 (12)
-
add
_ class _ or _ module (24) -
add
_ module (12) -
alias
_ method (12) -
all
_ classes _ and _ modules (12) - ancestors (12)
-
append
_ features (24) -
assert
_ instance _ of (1) - attr (36)
-
attr
_ accessor (12) -
attr
_ reader (12) -
attr
_ writer (12) - autoload (24)
- autoload? (12)
- bind (24)
- class (12)
-
class
_ eval (24) -
class
_ exec (12) -
class
_ variable _ defined? (12) -
class
_ variable _ get (12) -
class
_ variable _ set (12) -
class
_ variables (12) -
const
_ added (3) -
const
_ defined? (12) -
const
_ get (12) -
const
_ load (12) -
const
_ set (12) -
const
_ source _ location (12) - constants (24)
-
count
_ objects _ size (12) -
create
_ value (12) - debug (12)
-
def
_ module (12) -
default
_ event _ sources (12) -
define
_ method (48) -
defined
_ class (12) -
deprecate
_ constant (12) - dump (24)
-
each
_ classmodule (12) -
enum
_ for (48) - eval (24)
- extend (12)
-
extend
_ object (24) - extended (12)
- extern (12)
-
find
_ enclosing _ module _ named (12) -
find
_ local _ symbol (12) -
find
_ module _ named (24) - freeze (12)
-
global
_ variables (12) -
import
_ methods (4) - include (24)
- include? (12)
- included (12)
-
included
_ modules (12) -
infect
_ with _ assertions (1) -
initialize
_ classes _ and _ modules (12) - inspect (24)
-
instance
_ eval (24) -
instance
_ exec (12) -
instance
_ method (12) -
instance
_ methods (12) -
instance
_ variables (12) -
is
_ a? (12) -
kind
_ of? (12) - lambda? (12)
-
load
_ modules (12) -
local
_ variables (12) -
max
_ by (48) - method (12)
-
method
_ added (12) -
method
_ defined? (12) -
method
_ removed (12) -
method
_ undefined (12) - methods (12)
-
module
_ eval (24) -
module
_ exec (12) -
module
_ function (36) - modules (12)
- name (12)
- nesting (12)
- new (60)
-
num
_ modules (12) -
ole
_ type (12) - owner (24)
- prepend (12)
-
prepend
_ features (12) - prepended (12)
- private (75)
-
private
_ class _ method (24) -
private
_ constant (12) -
private
_ instance _ methods (12) -
private
_ method _ defined? (12) -
private
_ methods (12) - protected (48)
-
protected
_ instance _ methods (12) -
protected
_ method _ defined? (12) -
protected
_ methods (12) -
psych
_ yaml _ as (4) - public (75)
-
public
_ class _ method (24) -
public
_ constant (12) -
public
_ instance _ method (12) -
public
_ instance _ methods (12) -
public
_ method (12) -
public
_ method _ defined? (12) -
public
_ methods (12) -
rake
_ extension (12) -
rb
_ class _ path (12) - rdoc (12)
- refine (12)
-
remove
_ class _ variable (12) -
remove
_ classes _ and _ modules (12) -
remove
_ const (12) -
remove
_ instance _ variable (12) -
remove
_ method (12) -
respond
_ to? (12) -
ruby 1
. 6 feature (12) -
ruby 1
. 8 . 3 feature (12) -
ruby 1
. 8 . 4 feature (12) -
ruby2
_ keywords (18) -
ruby2
_ keywords _ hash? (6) -
singleton
_ class? (12) -
singleton
_ method (12) -
singleton
_ method _ added (12) -
singleton
_ method _ removed (12) -
singleton
_ method _ undefined (12) -
singleton
_ methods (12) - sizeof (12)
- struct (12)
-
to
_ enum (48) -
to
_ s (24) -
undef
_ method (12) - union (12)
-
used
_ modules (12) - using (24)
- value (12)
- warn (9)
- xmlrpc (3)
- yaml (12)
-
yaml
_ as (4) - クラス/メソッドの定義 (12)
- 制御構造 (12)
- 演算子式 (12)
検索結果
先頭5件
-
Module
# refine(klass) { . . . } -> Module (9229.0) -
引数 klass で指定したクラスまたはモジュールだけに対して、ブロックで指定した機能を提供で きるモジュールを定義します。定義した機能は Module#refine を使用せずに直 接 klass に対して変更を行う場合と異なり、限られた範囲のみ有効にできます。 そのため、既存の機能を局所的に修正したい場合などに用いる事ができます。
...モジュールだけに対して、ブロックで指定した機能を提供で
きるモジュールを定義します。定義した機能は Module#refine を使用せずに直
接 klass に対して変更を行う場合と異なり、限られた範囲のみ有効にできます。
そのた......ticles/0041/0041-200Special-refinement.html
* https://docs.ruby-lang.org/en/master/syntax/refinements_rdoc.html
定義した機能は main.using, Module#using を実行した場合のみ
有効になります。
@param klass 拡張する対象のクラスまたはモジュールを指定します......機能を持つ無名のモジュールを返します。
//emlist[例][ruby]{
class C
def foo
puts "C#foo"
end
end
module M
refine C do
def foo
puts "C#foo in M"
end
end
end
x = C.new
x.foo # => "C#foo"
using M
x = C.new
x.foo # => "C#foo in M"
//}
@see main.using... -
Module
. nesting -> [Class , Module] (9225.0) -
このメソッドを呼び出した時点でのクラス/モジュールのネスト情 報を配列に入れて返します。
...このメソッドを呼び出した時点でのクラス/モジュールのネスト情
報を配列に入れて返します。
//emlist[例][ruby]{
module Foo
module Bar
module Baz
p Module.nesting # => [Foo::Bar::Baz, Foo::Bar, Foo]
end
end
end
//}... -
Module
# ancestors -> [Class , Module] (9213.0) -
クラス、モジュールのスーパークラスとインクルードしているモジュール を優先順位順に配列に格納して返します。
...先順位順に配列に格納して返します。
//emlist[例][ruby]{
module Foo
end
class Bar
include Foo
end
class Baz < Bar
p ancestors
p included_modules
p superclass
end
# => [Baz, Bar, Foo, Object, Kernel, BasicObject]
# => [Foo, Kernel]
# => Bar
//}
@see Module#included_modules... -
Module
# append _ features(module _ or _ class) -> self (9213.0) -
モジュール(あるいはクラス)に self の機能を追加します。
...ラス)に 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
# using(module) -> self (9213.0) -
引数で指定したモジュールで定義された拡張を現在のクラス、モジュールで有 効にします。
...ルで有
効にします。
有効にした拡張の有効範囲については以下を参照してください。
* https://docs.ruby-lang.org/en/master/syntax/refinements_rdoc.html#label-Scope
@param module 有効にするモジュールを指定します。
@see Module#refine, main.using... -
Module
# constants(inherit = true) -> [Symbol] (9148.0) -
そのモジュール(またはクラス)で定義されている定数名の配列を返します。
...@see Module.constants, Kernel.#local_variables, Kernel.#global_variables, Object#instance_variables, Module#class_variables
//emlist[Module.constants と Module#constants の違い][ruby]{
# 出力の簡略化のため起動時の定数一覧を取得して後で差し引く
$clist = Module.const......を含む
p constants # => [:BAR]
# 出力に FOO は含まれない
p Module.constants - $clist # => [:BAR, :Bar, :Foo]
class Baz
# Baz は定数を含まない
p constants # => []
# ネストしたクラスでは、外側......のクラスで定義した定数は
# 参照可能なので、BAR は、Module.constants には含まれる
# (クラス Baz も Bar の定数なので同様)
p Module.constants - $clist # => [:BAR, :Baz, :Foo, :Bar]
end
end
//}... -
Module
# include(*mod) -> self (9136.0) -
モジュール mod をインクルードします。
...ます。
@param mod Module のインスタンス( Enumerable など)を指定します。
@raise ArgumentError 継承関係が循環してしまうような include を行った場合に発生します。
//emlist[例][ruby]{
module M
end
module M2
include M
end
module M
include M2
end
//}......わりに用いられており、 mix-in とも呼びます。
//emlist[例][ruby]{
class C
include FileTest
include Math
end
p C.ancestors
# => [C, Math, FileTest, Object, Kernel]
//}
モジュールの機能追加は、クラスの継承関係の間にそのモジュールが挿入
され......ールのほうが
先に行われます
(上の例の Module#ancestors の結果がメソッド探索の順序です)。
同じモジュールを二回以上 include すると二回目以降は無視されます。
//emlist[例][ruby]{
module M
end
class C1
include M
end
class C2 < C1
include... -
Module
# prepend _ features(mod) -> self (9134.0) -
Module#prepend から呼び出されるメソッドで、 prepend の処理の実体です。このメソッド自体は mod で指定した モジュール/クラスの継承チェインの先頭に self を追加します。
...Module#prepend から呼び出されるメソッドで、
prepend の処理の実体です。このメソッド自体は mod で指定した
モジュール/クラスの継承チェインの先頭に self を追加します。
このメソッドを上書きすることで、prepend の処理を変......れます
//emlist[例][ruby]{
class Recorder
RECORDS = []
end
module X
def self.prepend_features(mod)
Recorder::RECORDS << mod
end
end
class A
prepend X
end
class B
include X
end
class C
prepend X
end
Recorder::RECORDS # => [A, C]
//}
@see Module#prepend, Module#prepended... -
Module
# inspect -> String (9130.0) -
モジュールやクラスの名前を文字列で返します。
...y]{
module A
module B
end
p B.name #=> "A::B"
class C
end
end
p A.name #=> "A"
p A::B.name #=> "A::B"
p A::C.name #=> "A::C"
# 名前のないモジュール / クラス
p Module.new.name #=> nil
p Class.new.name #=> nil
p Module.new.to_s #=> "#<Module:0x00007f90b09112c8>"
p......Class.new.to_s #=> "#<Class:0x00007fa5c40b41b0>"
//}...