クラス
-
ARGF
. class (192) - BasicObject (24)
- Method (12)
- Module (132)
- Object (132)
- Thread (24)
-
Thread
:: Backtrace :: Location (12) - TracePoint (12)
- UnboundMethod (12)
モジュール
- Exception2MessageMapper (6)
- Kernel (28)
キーワード
- DelegateClass (12)
-
add
_ trace _ func (12) - ancestors (12)
- autoload (12)
-
class
_ eval (24) -
class
_ variables (12) -
const
_ defined? (12) - constants (12)
-
defined
_ class (12) - gets (36)
- include (12)
- inspect (12)
-
instance
_ eval (24) -
instance
_ variables (12) -
module
_ eval (24) - owner (24)
-
pretty
_ print (12) - print (12)
- printf (12)
- putc (12)
- puts (12)
- readline (36)
- readlines (36)
-
remove
_ const (12) - send (24)
-
set
_ trace _ func (12) -
singleton
_ method (12) - timeout (16)
-
to
_ a (36) -
to
_ ary (12) -
to
_ int (12) -
to
_ s (24) -
to
_ str (12)
検索結果
先頭5件
-
ARGF
. class # to _ a(rs , limit) -> Array (3007.0) -
ARGFの各行を配列に読み込んで返します。rsがnilの場合は要素に各ファイルを すべて読み込んだ配列を返します。
...。rsがnilの場合は要素に各ファイルを
すべて読み込んだ配列を返します。
@param rs 行区切り文字
@param limit 最大の読み込みバイト数
lines = ARGF.readlines
lines[0] # => "This is line one\n"
@see $/, Kernel.#readlines, IO#readlines... -
Exception2MessageMapper
# def _ e2message(exception _ class , message _ format) -> Class (237.0) -
すでに存在する例外クラス exception_class に、 エラーメッセージ用フォーマット message_format を関連づけます。
...する例外クラス exception_class に、
エラーメッセージ用フォーマット message_format を関連づけます。
このフォーマットは Exception2MessageMapper#Raise,
Exception2MessageMapper#Fail で使用します。
@param exception_class メッセージを登録する例......外クラスを指定します。
@param message_format メッセージのフォーマットを指定します。
Kernel.#sprintf のフォーマット文字列と同じ形式を使用できます。
@return exception_class を返します。... -
Method
# owner -> Class | Module (136.0) -
このメソッドが定義されている class か module を返します。
...定義されている class か module を返します。
//emlist[例][ruby]{
class Foo
def foo(arg)
"foo called with arg #{arg}"
end
end
m = Foo.new.method(:foo) # => #<Method: Foo#foo>
m.owner # => Foo
m = Foo.new.method(:puts) # => #<Method: Foo(Kernel)#puts>
m.owner # => Kernel
//}... -
Module
# ancestors -> [Class , Module] (126.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... -
UnboundMethod
# owner -> Class | Module (124.0) -
このメソッドが定義されている class か module を返します。
...このメソッドが定義されている class か module を返します。
//emlist[例][ruby]{
Integer.instance_method(:to_s).owner # => Integer
Integer.instance_method(:to_c).owner # => Numeric
Integer.instance_method(:hash).owner # => Kernel
//}... -
Module
# autoload(const _ name , feature) -> nil (77.0) -
定数 const_name を最初に参照した時に feature を Kernel.#require するように設定します。
...定数 const_name を最初に参照した時に feature を Kernel.#require するように設定します。
const_name が autoload 設定されていて、まだ定義されてない(ロードされていない)ときは、
autoload する対象を置き換えます。
const_name が(autoload......数しか指定できません。
@param feature Kernel.#require と同様な方法で autoload する対象を指定する。
//emlist[例][ruby]{
# ------- /tmp/foo.rb ---------
class Foo
class Bar
end
end
# ----- end of /tmp/foo.rb ----
class Foo
autoload :Bar, '/tmp/foo'
end
p Foo::Bar......にレシーバとして呼び出すこともできます。
//emlist[例][ruby]{
# ------- /tmp/foo.rb ---------
class Foo
class Bar
end
end
# ----- end of /tmp/foo.rb ----
class Foo
end
Foo.autoload :Bar, '/tmp/foo'
p Foo::Bar #=> Foo::Bar
//}
以下のように、autoload したライブ... -
Object
# to _ s -> String (43.0) -
オブジェクトの文字列表現を返します。
...
Kernel.#print や Kernel.#sprintf は文字列以外の
オブジェクトが引数に渡された場合このメソッドを使って文字列に変換し
ます。
//emlist[][ruby]{
class Foo
def initialize num
@num = num
end
end
it = Foo.new(40)
puts it #=> #<Foo:0x2b69110>
class Foo......def to_s
"Class:Foo Number:#{@num}"
end
end
puts it #=> Class:Foo Number:40
//}
@see Object#to_str,Kernel.#String... -
BasicObject
# instance _ eval {|obj| . . . } -> object (37.0) -
オブジェクトのコンテキストで文字列 expr またはオブジェクト自身をブロックパラメータとするブロックを 評価してその結果を返します。
...hod を参照してください。
BasicObject を継承して作ったクラス内で instance_eval する場合はトップレベルの定数や Kernel モジュールに定義されているメソッドは見えません。
これは、トップレベルの定数が Object 以下に作成され......うに実行されます。
スタックトレースの表示などを差し替えることができます。
//emlist[例][ruby]{
class Foo
def initialize data
@key = data
end
private
def do_fuga
p 'secret'
end
end
some = Foo.new 'XXX'
some.instance_eval{p @key} #=......imeError)
//}
//emlist[例][ruby]{
class Bar < BasicObject
def call1
instance_eval("::ENV.class")
end
def call2
instance_eval("ENV.class")
end
end
bar = Bar.new
bar.call1 # => Object
bar.call2 # raise NameError
//}
@see Module#module_eval, Kernel.#eval, BasicObject#instance_exec... -
BasicObject
# instance _ eval(expr , filename = "(eval)" , lineno = 1) -> object (37.0) -
オブジェクトのコンテキストで文字列 expr またはオブジェクト自身をブロックパラメータとするブロックを 評価してその結果を返します。
...hod を参照してください。
BasicObject を継承して作ったクラス内で instance_eval する場合はトップレベルの定数や Kernel モジュールに定義されているメソッドは見えません。
これは、トップレベルの定数が Object 以下に作成され......うに実行されます。
スタックトレースの表示などを差し替えることができます。
//emlist[例][ruby]{
class Foo
def initialize data
@key = data
end
private
def do_fuga
p 'secret'
end
end
some = Foo.new 'XXX'
some.instance_eval{p @key} #=......imeError)
//}
//emlist[例][ruby]{
class Bar < BasicObject
def call1
instance_eval("::ENV.class")
end
def call2
instance_eval("ENV.class")
end
end
bar = Bar.new
bar.call1 # => Object
bar.call2 # raise NameError
//}
@see Module#module_eval, Kernel.#eval, BasicObject#instance_exec... -
Module
# constants(inherit = true) -> [Symbol] (37.0) -
そのモジュール(またはクラス)で定義されている定数名の配列を返します。
...stants, Kernel.#local_variables, Kernel.#global_variables, Object#instance_variables, Module#class_variables
//emlist[Module.constants と Module#constants の違い][ruby]{
# 出力の簡略化のため起動時の定数一覧を取得して後で差し引く
$clist = Module.constants
class Foo......FOO = 1
end
class Bar
BAR = 1
# Bar は BAR を含む
p constants # => [:BAR]
# 出力に FOO は含まれない
p Module.constants - $clist # => [:BAR, :Bar, :Foo]
class Baz
# Baz は定数を含まない
p constants # => [...