種類
ライブラリ
- ビルトイン (1688)
- drb (11)
- erb (11)
-
fiddle
/ import (77) - forwardable (22)
-
irb
/ context (11) -
minitest
/ spec (1) -
minitest
/ unit (1) - monitor (11)
-
mutex
_ m (33) - objspace (11)
- profiler (6)
- psych (8)
- rake (11)
-
rdoc
/ class _ module (11) -
rdoc
/ code _ object (11) -
rdoc
/ context (99) -
rdoc
/ normal _ module (11) -
rdoc
/ stats (22) -
rdoc
/ top _ level (44) - win32ole (33)
クラス
- BasicObject (66)
- Class (22)
- ERB (11)
-
Enumerator
:: Lazy (55) - Hash (5)
-
IRB
:: Context (11) - Method (33)
- Module (970)
- Object (220)
- Proc (16)
-
RDoc
:: CodeObject (11) -
RDoc
:: Context (99) -
RDoc
:: Stats (22) -
RDoc
:: TopLevel (44) - Refinement (3)
- SystemCallError (11)
- TracePoint (11)
- UnboundMethod (22)
- WIN32OLE (11)
-
WIN32OLE
_ TYPE (22)
モジュール
- Enumerable (44)
-
Fiddle
:: Importer (77) - Kernel (55)
- Marshal (22)
-
MiniTest
:: Assertions (1) -
Mutex
_ m (22) - ObjectSpace (11)
- Warning (8)
オブジェクト
- main (90)
キーワード
-
1
. 6 . 8から1 . 8 . 0への変更点(まとめ) (11) - < (11)
- <= (11)
- <=> (11)
- === (33)
- > (11)
- >= (11)
- Class (11)
- ClassModule (11)
- DRbProtocol (11)
- DomainError (11)
- Enumerator (11)
- Forwardable (11)
- Marshal フォーマット (11)
- MonitorMixin (11)
-
Mutex
_ m (11) -
NEWS for Ruby 2
. 0 . 0 (11) -
NEWS for Ruby 2
. 1 . 0 (11) -
NEWS for Ruby 2
. 3 . 0 (9) -
NEWS for Ruby 2
. 4 . 0 (8) -
NEWS for Ruby 2
. 5 . 0 (7) -
NEWS for Ruby 2
. 6 . 0 (6) -
NEWS for Ruby 2
. 7 . 0 (5) -
NEWS for Ruby 3
. 0 . 0 (4) -
NEWS for Ruby 3
. 1 . 0 (3) - NormalModule (11)
-
Profiler
_ _ (6) - RMODULE (11)
- Ruby プログラムの実行 (11)
- Ruby用語集 (11)
- SingleForwardable (11)
- UnboundMethod (11)
-
add
_ class _ or _ module (22) -
add
_ module (11) -
alias
_ method (11) -
all
_ classes _ and _ modules (11) - ancestors (11)
-
append
_ features (22) -
assert
_ instance _ of (1) - attr (33)
-
attr
_ accessor (11) -
attr
_ reader (11) -
attr
_ writer (11) - autoload (22)
- autoload? (11)
- bind (22)
-
boot
_ defclass (11) - class (11)
-
class
_ eval (22) -
class
_ exec (11) -
class
_ variable _ defined? (11) -
class
_ variable _ get (11) -
class
_ variable _ set (11) -
class
_ variables (11) -
const
_ added (2) -
const
_ defined? (11) -
const
_ get (11) -
const
_ load (11) -
const
_ missing (11) -
const
_ set (11) -
const
_ source _ location (5) - constants (22)
-
count
_ objects _ size (11) -
create
_ value (11) - debug (11)
-
def
_ module (11) -
default
_ event _ sources (11) -
define
_ method (44) -
defined
_ class (11) -
deprecate
_ constant (9) - drb (11)
- dump (22)
- e2mmap (6)
-
each
_ classmodule (11) -
enum
_ for (44) - eval (22)
- extend (11)
-
extend
_ object (22) - extended (11)
- extern (11)
- fiddle (11)
-
fiddle
/ import (11) -
fiddle
/ types (11) -
find
_ enclosing _ module _ named (11) -
find
_ local _ symbol (22) -
find
_ module _ named (22) -
find
_ symbol (11) - freeze (11)
-
global
_ variables (11) -
import
_ methods (3) - include (22)
- include? (11)
-
include
_ class _ new (11) - included (11)
-
included
_ modules (11) -
infect
_ with _ assertions (1) -
initialize
_ classes _ and _ modules (11) - inspect (22)
-
instance
_ eval (22) -
instance
_ exec (11) -
instance
_ method (11) -
instance
_ methods (11) -
instance
_ variables (11) -
is
_ a? (11) -
kind
_ of? (11) - lambda? (11)
-
load
_ modules (11) -
local
_ variables (11) -
max
_ by (44) - method (11)
-
method
_ added (11) -
method
_ defined? (11) -
method
_ removed (11) -
method
_ undefined (11) - methods (11)
-
module
_ eval (22) -
module
_ exec (11) -
module
_ function (19) -
module
_ setup (11) - modules (11)
- name (11)
- nesting (11)
- new (55)
-
num
_ modules (11) -
num
_ modules= (11) -
ole
_ type (11) -
original
_ module (11) - owner (22)
- prepend (11)
-
prepend
_ features (11) - prepended (11)
- private (46)
-
private
_ class _ method (15) -
private
_ constant (11) -
private
_ instance _ methods (11) -
private
_ method _ defined? (11) -
private
_ methods (11) - protected (23)
-
protected
_ instance _ methods (11) -
protected
_ method _ defined? (11) -
protected
_ methods (11) -
psych
_ yaml _ as (4) - public (46)
-
public
_ class _ method (15) -
public
_ constant (11) -
public
_ instance _ method (11) -
public
_ instance _ methods (11) -
public
_ method (11) -
public
_ method _ defined? (11) -
public
_ methods (11) - rake (11)
-
rake
_ extension (11) -
rb
_ class _ instance _ methods (11) -
rb
_ class _ path (11) -
rb
_ class _ private _ instance _ methods (11) -
rb
_ class _ protected _ instance _ methods (11) -
rb
_ define _ module (11) -
rb
_ define _ module _ function (11) -
rb
_ define _ module _ id (11) -
rb
_ define _ module _ under (11) -
rb
_ extend _ object (11) -
rb
_ include _ module (11) -
rb
_ mod _ append _ features (11) -
rb
_ mod _ include (11) -
rb
_ mod _ included _ modules (11) -
rb
_ mod _ initialize (11) -
rb
_ mod _ modfunc (11) -
rb
_ mod _ module _ eval (11) -
rb
_ mod _ name (11) -
rb
_ mod _ private (11) -
rb
_ mod _ protected (11) -
rb
_ mod _ public (11) -
rb
_ mod _ remove _ method (11) -
rb
_ module _ new (11) -
rb
_ module _ s _ alloc (11) - rdoc (11)
-
rdoc
/ class _ module (11) -
rdoc
/ normal _ module (11) - refine (11)
-
remove
_ class _ variable (11) -
remove
_ classes _ and _ modules (11) -
remove
_ const (11) -
remove
_ instance _ variable (11) -
remove
_ method (11) -
respond
_ to? (11) - rss (11)
-
ruby 1
. 6 feature (11) -
ruby 1
. 8 . 2 feature (11) -
ruby 1
. 8 . 3 feature (11) -
ruby 1
. 8 . 4 feature (11) -
ruby 1
. 9 feature (11) -
ruby2
_ keywords (10) -
ruby2
_ keywords _ hash? (5) -
singleton
_ class? (11) -
singleton
_ method (11) -
singleton
_ method _ added (11) -
singleton
_ method _ removed (11) -
singleton
_ method _ undefined (11) -
singleton
_ methods (11) - sizeof (11)
-
specific
_ eval (11) - struct (11)
-
to
_ enum (44) -
to
_ s (22) -
undef
_ method (11) - union (11)
-
used
_ modules (8) - using (22)
- value (11)
- warn (8)
- xmlrpc (3)
- yaml (11)
-
yaml
_ as (4) - クラス/メソッドの定義 (11)
- 制御構造 (11)
- 変数と定数 (11)
- 字句構造 (11)
- 演算子式 (11)
検索結果
先頭5件
-
Module
# included(class _ or _ module) -> () (21141.0) -
self が Module#include されたときに対象のクラスまたはモジュー ルを引数にしてインタプリタがこのメソッドを呼び出します。
...self が Module#include されたときに対象のクラスまたはモジュー
ルを引数にしてインタプリタがこのメソッドを呼び出します。
@param class_or_module Module#include を実行したオブジェクト
//emlist[例][ruby]{
module Foo
def self.included(mod)......p "#{mod} include #{self}"
end
end
class Bar
include Foo
end
# => "Bar include Foo"
//}
@see Module#append_features... -
Module
# prepend(*modules) -> self (21136.0) -
指定したモジュールを self の継承チェインの先頭に「追加する」ことで self の定数、メソッド、モジュール変数を「上書き」します。
...追加されるため、結果として self で定義されたメソッドは
override されます。
modules で指定したモジュールは後ろから順に処理されるため、
modules の先頭が最も優先されます。
また、継承によってこの「上書き」を処理す......のモジュール/クラスのメソッドを呼び出すことができます。
実際の処理は modules の各要素の prepend_features を後ろから順に呼びだすだけです。
Module#prepend_features が継承チェインの改変を実行し、結果として上のような
処理......とで
prepend の処理を追加/変更できます。
@param modules prepend する Module を指定します
@see Module#prepend_features, Module#prepended
//emlist[例][ruby]{
# super と prepend の組み合わせの例
module X
def foo
puts "X1" # (1x)
super # (2x)
puts "X2" #... -
Module
. new -> Module (21132.0) -
名前の付いていないモジュールを新しく生成して返します。
...ジュールのコンテキストでブロックを実行します。
//emlist[例][ruby]{
mod = Module.new
mod.module_eval {|m|
# ...
}
mod
//}
と同じです。
ブロックの実行は Module#initialize が行います。
ブロックを与えた場合も生成したモジュールを返し......ュールの名前は、
そのモジュールが代入されている定数名のいずれかです。
//emlist[例][ruby]{
m = Module.new
p m # => #<Module 0lx40198a54>
p m.name # => nil # まだ名前は未定
Foo = m
# m.name # ここで m.name を呼べば m... -
Module
. new {|mod| . . . } -> Module (21132.0) -
名前の付いていないモジュールを新しく生成して返します。
...ジュールのコンテキストでブロックを実行します。
//emlist[例][ruby]{
mod = Module.new
mod.module_eval {|m|
# ...
}
mod
//}
と同じです。
ブロックの実行は Module#initialize が行います。
ブロックを与えた場合も生成したモジュールを返し......ュールの名前は、
そのモジュールが代入されている定数名のいずれかです。
//emlist[例][ruby]{
m = Module.new
p m # => #<Module 0lx40198a54>
p m.name # => nil # まだ名前は未定
Foo = m
# m.name # ここで m.name を呼べば m... -
Module
# refine(klass) { . . . } -> Module (21129.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 拡張する対象のクラスを指定します。
@return ブロッ......モジュールだけに対して、ブロックで指定した機能を提供で
きるモジュールを定義します。定義した機能は 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"
/... -
Module
. nesting -> [Class , Module] (21125.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] (21113.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......先順位順に配列に格納して返します。
//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 (21113.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 (21113.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] (21048.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 Module.constants - $clist # => [:BAR, :Bar, :Foo]
class Baz
# Baz は定数を含まない
p constants # => []
# ネストしたクラスでは、外側のクラスで定義した定数は
# 参照可能なので、BAR は、Module.constant......s には含まれる
# (クラス Baz も Bar の定数なので同様)
p Module.constants - $clist # => [:BAR, :Baz, :Foo, :Bar]
end
end
//}...