488件ヒット
[1-100件を表示]
(0.285秒)
ライブラリ
- ビルトイン (488)
キーワード
- [] (12)
- []= (12)
- autoload (12)
-
class
_ variable _ get (12) -
const
_ get (12) -
const
_ missing (12) -
const
_ set (12) -
deprecate
_ constant (12) -
initialize
_ copy (12) -
instance
_ eval (24) -
instance
_ method (12) -
local
_ variable _ get (12) -
local
_ variable _ set (12) -
local
_ variables (10) - method (12)
- name (12)
- private (48)
-
private
_ constant (12) - protected (48)
- public (48)
-
public
_ constant (12) -
public
_ instance _ method (12) -
public
_ method (12) - receiver (10)
-
remove
_ class _ variable (12) -
remove
_ const (12) -
remove
_ instance _ variable (12) -
remove
_ method (12) -
singleton
_ method (12) -
to
_ s (12) -
undef
_ method (12)
検索結果
先頭5件
-
NameError
# name -> Symbol (17013.0) -
この例外オブジェクトを発生させる原因となった 変数や定数、メソッドの名前をシンボルで返します。
...クトを発生させる原因となった
変数や定数、メソッドの名前をシンボルで返します。
例:
begin
foobar
rescue NameError => err
p err # => #<NameError: undefined local variable or method `foobar' for main:Object>
p err.name # => :foobar
end... -
NameError
# to _ s -> String (17013.0) -
例外オブジェクトを文字列に変換して返します。
...例外オブジェクトを文字列に変換して返します。
例:
begin
foobar
rescue NameError => err
p err # => #<NameError: undefined local variable or method `foobar' for main:Object>
p err.to_s # => "undefined local variable or method `foobar' for main:Object"... -
NameError
# local _ variables -> [Symbol] (17007.0) -
self が発生した時に定義されていたローカル変数名の一覧を返します。
...発生した時に定義されていたローカル変数名の一覧を返します。
内部での使用に限ります。
例:
def foo
begin
b = "bar"
c = 123
d
rescue NameError => err
p err.local_variables #=> [:b, :c, :err]
end
end
a = "buz"
foo... -
NameError
# receiver -> object (17007.0) -
self が発生した時のレシーバオブジェクトを返します。
...lf が発生した時のレシーバオブジェクトを返します。
例:
class Sample
def foo
return "foo"
end
end
bar = Sample.new
begin
bar.bar
rescue NameError => err
p err.receiver # => #<Sample:0x007fd4d89b3110>
p err.receiver.foo # => "foo"
end... -
Module
# const _ get(name , inherit = true) -> object (8019.0) -
name で指定される名前の定数の値を取り出します。
...を指定するとスーパークラスや include したモジュールで
定義された定数は対象にはなりません。
@raise NameError 定数が定義されていないときに発生します。
//emlist[例][ruby]{
module Bar
BAR = 1
end
class Object
include Bar
end
# Obj......1
# 定義されていない定数
p Baz.const_get(:NOT_DEFINED) #=> raise NameError
# 第二引数に false を指定すると自分自身に定義された定数から探す
p Baz.const_get(:BAR, false) #=> raise NameError
# 完全修飾名を指定すると include や自分自身へ定義され... -
Module
# private _ constant(*name) -> self (8019.0) -
name で指定した定数の可視性を private に変更します。
...me で指定した定数の可視性を private に変更します。
@param name 0 個以上の String か Symbol を指定します。
@raise NameError 存在しない定数を指定した場合に発生します。
@return self を返します。
@see Module#public_constant, Object#untrusted?......Foo
BAR = 'bar'
class Baz; end
QUX = 'qux'
class Quux; end
private_constant :QUX
private_constant :Quux
end
Foo::BAR # => "bar"
Foo::Baz # => Foo::Baz
Foo::QUX # => NameError: private constant Foo::QUX referenced
Foo::Quux # => NameError: private constant Foo::Quux referenced
//}......me で指定した定数の可視性を private に変更します。
@param name 0 個以上の String か Symbol を指定します。
@raise NameError 存在しない定数を指定した場合に発生します。
@return self を返します。
@see Module#public_constant
//emlist[例][rub... -
Binding
# local _ variable _ get(symbol) -> object (8013.0) -
引数 symbol で指定した名前のローカル変数に設定された値を返します。
...クトで指定します。
@raise NameError 引数 symbol で指定したローカル変数が未定義の場合に発生します。
//emlist[例][ruby]{
def foo
a = 1
binding.local_variable_get(:a) # => 1
binding.local_variable_get(:b) # => NameError
end
//}
このメソッドは以下... -
Module
# autoload(const _ name , feature) -> nil (8013.0) -
定数 const_name を最初に参照した時に feature を Kernel.#require するように設定します。
...義しない場
合、NameError が発生します。
//emlist[例][ruby]{
# ------- /tmp/bar.rb ---------
class Bar
end
# ----- end of /tmp/bar.rb ----
class Foo
autoload :Bar, '/tmp/bar.rb'
end
p Foo::Bar
#=> -:4:in `<main>': uninitialized constant Foo::Bar (NameError)
//}
@see Kernel.#autolo... -
Module
# deprecate _ constant(*name) -> self (8013.0) -
name で指定した定数を deprecate に設定します。 deprecate に設定した定数を参照すると警告メッセージが表示されます。
...@raise NameError 存在しない定数を指定した場合に発生します。
@return self を返します。
//emlist[例][ruby]{
FOO = 123
Object.deprecate_constant(:FOO) # => Object
FOO
# warning: constant ::FOO is deprecated
# => 123
Object.deprecate_constant(:BAR)
# NameError: constant...