232件ヒット
[1-100件を表示]
(0.136秒)
種類
- インスタンスメソッド (162)
- 文書 (37)
- 特異メソッド (11)
- 定数 (11)
- クラス (11)
クラス
- Binding (10)
- ERB (11)
- Module (22)
- NameError (9)
- Object (44)
- Thread (11)
- TracePoint (11)
-
WIN32OLE
_ TYPE (11) -
WIN32OLE
_ VARIABLE (55)
キーワード
- DATA (11)
-
NEWS for Ruby 3
. 0 . 0 (4) - Ruby用語集 (11)
-
WIN32OLE
_ VARIABLE (11) - binding (11)
-
class
_ variables (11) - constants (11)
-
initialize
_ copy (11) -
instance
_ variable _ defined? (11) -
instance
_ variable _ get (11) -
local
_ variables (19) - name (11)
- new (11)
-
ole
_ type (11) -
ole
_ type _ detail (11) -
ruby 1
. 8 . 3 feature (11) -
thread
_ variable _ set (11) -
to
_ s (11) - value (11)
- 変数と定数 (11)
検索結果
先頭5件
-
WIN32OLE
_ TYPE # variables -> [WIN32OLE _ VARIABLE] (24313.0) -
型が持つ変数を取得します。
...メンバ変数の情報を
WIN32OLE_VARIABLEオブジェクトの配列として返します。
@return 型が持つ変数情報をWIN32OLE_VARIABLEの配列として返します。
変数を持たない場合は空配列を返します。
@raise WIN32OLERuntimeError 型属性が取得で......tobj = WIN32OLE_TYPE.new('Microsoft Excel 14.0 Object Library', 'XlSheetType')
vars = tobj.variables
vars.each do |v|
puts "#{v.name} = #{v.value}"
end
上記を実行すると以下の出力が得られます。
xlChart = -4109
xlDialogSheet = -4116
xlExcel4IntlMacro......Sheet = 4
xlExcel4MacroSheet = 3
xlWorksheet = -4167
@see WIN32OLE_VARIABLE... -
TracePoint
# binding -> Binding (15418.0) -
発生したイベントによって生成された Binding オブジェクトを返します。
...発生したイベントによって生成された Binding オブジェクトを返します。
//emlist[例][ruby]{
def foo(ret)
ret
end
trace = TracePoint.new(:call) do |tp|
p tp.binding.local_variables # => [:ret]
end
trace.enable
foo 1
//}... -
TracePoint
# binding -> Binding | nil (15418.0) -
発生したイベントによって生成された Binding オブジェクトを返します。
...れた Binding オブジェクトを返します。
C で記述されたメソッドは binding を生成しないため、
:c_call および :c_return イベントに対しては nil を返すことに注意してください。
//emlist[例][ruby]{
def foo(ret)
ret
end
trace = TracePoint.new(:......call) do |tp|
p tp.binding.local_variables # => [:ret]
end
trace.enable
foo 1
//}... -
Binding
# local _ variables -> [Symbol] (15225.0) -
ローカル変数の一覧を Symbol の配列で返します。
...カル変数の一覧を Symbol の配列で返します。
//emlist[例][ruby]{
def foo
a = 1
2.times do |n|
binding.local_variables #=> [:a, :n]
end
end
//}
このメソッドは以下のコードと同様の動作をします。
//emlist[][ruby]{
binding.eval("local_variables")
//}... -
Module
# class _ variables(inherit = true) -> [Symbol] (12249.0) -
クラス/モジュールに定義されているクラス変数の名前の配列を返します。
...am inherit false を指定しない場合はスーパークラスやインクルードして
いるモジュールのクラス変数を含みます。
//emlist[例][ruby]{
class One
@@var1 = 1
end
class Two < One
@@var2 = 2
end
One.class_variables # => [:@@var1]
Two.class_variab......les # => [:@@var2, :@@var1]
Two.class_variables(false) # => [:@@var2]
//}
@see Module.constants, Kernel.#local_variables, Kernel.#global_variables, Object#instance_variables, Module#constants... -
NameError
# local _ variables -> [Symbol] (12219.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... -
Object
# instance _ variable _ defined?(var) -> bool (12218.0) -
インスタンス変数 var が定義されていたら真を返します。
...//emlist[][ruby]{
class Fred
def initialize(p1, p2)
@a, @b = p1, p2
end
end
fred = Fred.new('cat', 99)
p fred.instance_variable_defined?(:@a) #=> true
p fred.instance_variable_defined?("@b") #=> true
p fred.instance_variable_defined?("@c") #=> false
//}
@see Object#instance_variable_......get,Object#instance_variable_set,Object#instance_variables... -
変数と定数 (6216.0)
-
変数と定数 * local * instance * class * class_var_scope * global * pseudo * const * prio
...変数と定数
* local
* instance
* class
* class_var_scope
* global
* pseudo
* const
* prio
Ruby の変数と定数の種別は変数名の最初の一文字によって、
ローカル変数、
インスタンス変数、
クラス変数、
グローバル変数、
定数
のい......数の一部には
「`$'+1文字の記号」という変数があります(builtinを参照)。変数名
の長さにはメモリのサイズ以外の制限はありません。
===[a:local] ローカル変数
//emlist[例][ruby]{
foobar
//}
小文字または`_'で始まる識別子はローカ......す。
//emlist[][ruby]{
# (A) の部分はスコープに入らない
2.times {
p defined?(v) # (A)
v = 1 # ここ(宣言開始)から
p v # ここ(ブロックの終り)までが v のスコープ
}
# => nil
# 1
# nil <- これが nil であるこ... -
Object
# initialize _ copy(obj) -> object (6148.0) -
(拡張ライブラリによる) ユーザ定義クラスのオブジェクトコピーの初期化メソッド。
...
initialize_copy は、Ruby インタプリタが知り得ない情報をコピーするた
めに使用(定義)されます。例えば C 言語でクラスを実装する場合、情報
をインスタンス変数に保持させない場合がありますが、そういった内部情
報を init......mlist[][ruby]{
obj = Object.new
class <<obj
attr_accessor :foo
def bar
:bar
end
end
def check(obj)
puts "instance variables: #{obj.inspect}"
puts "tainted?: #{obj.tainted?}"
print "singleton methods: "
begin
p obj.bar
rescue NameError
p $!
end
end
obj.foo = 1
obj.tain......Object.new.send(:initialize_copy, obj)
#=> instance variables: #<Object:0x4019c9d4>
# tainted?: false
# singleton methods: #<NoMethodError: ...>
check obj.dup
#=> instance variables: #<Object:0x4019c9c0 @foo=1>
# tainted?: true
# singleton meth......//emlist[][ruby]{
obj = Object.new
class <<obj
attr_accessor :foo
def bar
:bar
end
end
def check(obj)
puts "instance variables: #{obj.inspect}"
print "singleton methods: "
begin
p obj.bar
rescue NameError
p $!
end
end
obj.foo = 1
check Object.new.send(:initialize_cop......obj)
#=> instance variables: #<Object:0x4019c9d4>
# singleton methods: #<NoMethodError: ...>
check obj.dup
#=> instance variables: #<Object:0x4019c9c0 @foo=1>
# singleton methods: #<NoMethodError: ...>
check obj.clone
#=> instance variables: #<Object:0x401... -
Object
# instance _ variable _ get(var) -> object | nil (6118.0) -
オブジェクトのインスタンス変数の値を取得して返します。
...ば nil を返します。
@param var インスタンス変数名を文字列か Symbol で指定します。
//emlist[][ruby]{
class Foo
def initialize
@foo = 1
end
end
obj = Foo.new
p obj.instance_variable_get("@foo") #=> 1
p obj.instance_variable_get(:@foo) #=> 1
p obj.instanc......e_variable_get(:@bar) #=> nil
//}
@see Object#instance_variable_set,Object#instance_variables,Object#instance_variable_defined?... -
Thread
# thread _ variable _ set(key , value) (6112.0) -
引数 key で指定した名前のスレッドローカル変数に引数 value をセットしま す。
...(Fiber ローカル変数)と
異なり、セットした変数は Fiber を切り替えても共通で使える事に注意してく
ださい。
//emlist[例][ruby]{
thr = Thread.new do
Thread.current.thread_variable_set(:cat, 'meow')
Thread.current.thread_variable_set("dog", 'woof')
end
thr.......join # => #<Thread:0x401b3f10 dead>
thr.thread_variables # => [:dog, :cat]
//}
@see Thread#thread_variable_get, Thread#[]...