種類
ライブラリ
- ビルトイン (1966)
- drb (12)
- erb (12)
-
fiddle
/ import (84) - forwardable (24)
-
irb
/ context (12) -
minitest
/ spec (1) -
minitest
/ unit (1) - monitor (12)
-
mutex
_ m (36) - objspace (12)
- profiler (6)
- psych (8)
- rake (12)
-
rdoc
/ class _ module (12) -
rdoc
/ code _ object (12) -
rdoc
/ context (108) -
rdoc
/ normal _ module (12) -
rdoc
/ stats (24) -
rdoc
/ top _ level (48) - win32ole (36)
クラス
- BasicObject (72)
- Class (24)
- ERB (12)
-
Enumerator
:: Lazy (60) - Hash (6)
-
IRB
:: Context (12) - Method (36)
- Module (1176)
- Object (240)
- Proc (18)
-
RDoc
:: CodeObject (12) -
RDoc
:: Context (108) -
RDoc
:: Stats (24) -
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)
- >= (12)
- Class (12)
- ClassModule (12)
- DRbProtocol (12)
- DomainError (12)
- Enumerator (12)
- Forwardable (12)
- Marshal フォーマット (12)
- MonitorMixin (12)
-
Mutex
_ m (12) -
NEWS for Ruby 2
. 0 . 0 (12) -
NEWS for Ruby 2
. 1 . 0 (12) -
NEWS for Ruby 2
. 3 . 0 (10) -
NEWS for Ruby 2
. 4 . 0 (9) -
NEWS for Ruby 2
. 5 . 0 (8) -
NEWS for Ruby 2
. 6 . 0 (7) -
NEWS for Ruby 2
. 7 . 0 (6) -
NEWS for Ruby 3
. 0 . 0 (5) -
NEWS for Ruby 3
. 1 . 0 (4) - NormalModule (12)
-
Profiler
_ _ (6) - RMODULE (12)
- Ruby プログラムの実行 (12)
- Ruby用語集 (12)
- SingleForwardable (12)
- UnboundMethod (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)
-
boot
_ defclass (12) - 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
_ missing (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) - drb (12)
- dump (24)
- e2mmap (6)
-
each
_ classmodule (12) -
enum
_ for (48) - eval (24)
- extend (12)
-
extend
_ object (24) - extended (12)
- extern (12)
- fiddle (12)
-
fiddle
/ import (12) -
fiddle
/ types (12) -
find
_ enclosing _ module _ named (12) -
find
_ local _ symbol (24) -
find
_ module _ named (24) -
find
_ symbol (12) - freeze (12)
-
global
_ variables (12) -
import
_ methods (4) - include (24)
- include? (12)
-
include
_ class _ new (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) -
module
_ setup (12) - modules (12)
- name (12)
- nesting (12)
- new (60)
-
num
_ modules (12) -
num
_ modules= (12) -
ole
_ type (12) -
original
_ module (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 (12)
-
rake
_ extension (12) -
rb
_ class _ instance _ methods (12) -
rb
_ class _ path (12) -
rb
_ class _ private _ instance _ methods (12) -
rb
_ class _ protected _ instance _ methods (12) -
rb
_ define _ module (12) -
rb
_ define _ module _ function (12) -
rb
_ define _ module _ id (12) -
rb
_ define _ module _ under (12) -
rb
_ extend _ object (12) -
rb
_ include _ module (12) -
rb
_ mod _ append _ features (12) -
rb
_ mod _ include (12) -
rb
_ mod _ included _ modules (12) -
rb
_ mod _ initialize (12) -
rb
_ mod _ modfunc (12) -
rb
_ mod _ module _ eval (12) -
rb
_ mod _ name (12) -
rb
_ mod _ private (12) -
rb
_ mod _ protected (12) -
rb
_ mod _ public (12) -
rb
_ mod _ remove _ method (12) -
rb
_ module _ new (12) -
rb
_ module _ s _ alloc (12) - rdoc (12)
-
rdoc
/ class _ module (12) -
rdoc
/ normal _ module (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) - rss (12)
-
ruby 1
. 6 feature (12) -
ruby 1
. 8 . 2 feature (12) -
ruby 1
. 8 . 3 feature (12) -
ruby 1
. 8 . 4 feature (12) -
ruby 1
. 9 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)
-
specific
_ eval (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)
- 字句構造 (12)
- 演算子式 (12)
検索結果
先頭5件
-
Module
# module _ eval(expr , fname = "(eval)" , lineno = 1) -> object (24114.0) -
モジュールのコンテキストで文字列 expr またはモジュール自身をブロックパラメータとするブロックを 評価してその結果を返します。
...ことです。
つまり、そのモジュールの定義式の中にあるかのように実行されます。
ただし、ローカル変数は module_eval/class_eval の外側のスコープと共有します。
定数とクラス変数のスコープは、文字列が与えられた場合と......列が渡された場合は、モジュール定義式内と同じスコープになる。つまり、この場合は
# class C
# X = 2
# end
# と書いたのと同じ意味になる。
C.class_eval 'X = 2'
p X #=> 1
p C::X #=> 2
//}
@see BasicObject#instance_eval, Module.new, Kernel.#eval... -
Module
# prepended(class _ or _ module) -> () (21159.0) -
self が Module#prepend されたときに対象のクラスまたはモジュールを 引数にしてインタプリタがこのメソッドを呼び出します。
...self が Module#prepend されたときに対象のクラスまたはモジュールを
引数にしてインタプリタがこのメソッドを呼び出します。
@param class_or_module Module#prepend を実行したオブジェクト
//emlist[例][ruby]{
module A
def self.prepended(mod)......puts "#{self} prepended to #{mod}"
end
end
module Enumerable
prepend A
end
# => "A prepended to Enumerable"
//}
@see Module#included, Module#prepend, Module#prepend_features... -
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 拡張する対象のクラスまたはモジュールを指定します......ックで指定した機能を持つ無名のモジュールを返します。
//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...