136件ヒット
[1-100件を表示]
(0.153秒)
クラス
- Binding (6)
- Module (11)
- NameError (9)
- Object (66)
- TracePoint (11)
-
WIN32OLE
_ TYPE (11) -
WIN32OLE
_ VARIABLE (22)
キーワード
- binding (11)
- constants (11)
-
initialize
_ copy (11) -
instance
_ variable _ defined? (11) -
instance
_ variable _ get (11) -
instance
_ variable _ set (11) -
instance
_ variables (11) -
local
_ variables (9) -
ole
_ type (11) -
ole
_ type _ detail (11) -
pretty
_ print _ instance _ variables (11) -
source
_ location (6)
検索結果
先頭5件
-
WIN32OLE
_ TYPE # variables -> [WIN32OLE _ VARIABLE] (21108.0) -
型が持つ変数を取得します。
...ERuntimeError 型属性が取得できない場合に通知します。
tobj = WIN32OLE_TYPE.new('Microsoft Excel 14.0 Object Library', 'XlSheetType')
vars = tobj.variables
vars.each do |v|
puts "#{v.name} = #{v.value}"
end
上記を実行すると以下の出力が得られます... -
Object
# pretty _ print _ instance _ variables -> [String | Symbol] (18302.0) -
プリティプリント時に表示すべき自身のインスタンス変数名の配列をソートして返します。 返されたインスタンス変数はプリティプリント時に表示されます。
...表示すべき自身のインスタンス変数名の配列をソートして返します。
返されたインスタンス変数はプリティプリント時に表示されます。
pp に表示したくないインスタンス変数がある場合にこのメソッドを再定義します。... -
Object
# initialize _ copy(obj) -> object (6137.0) -
(拡張ライブラリによる) ユーザ定義クラスのオブジェクトコピーの初期化メソッド。
...ます。ただ
し、self のインスタンス変数や特異メソッドは変化しません。
Object#clone, Object#dupの内部で使われています。
initialize_copy は、Ruby インタプリタが知り得ない情報をコピーするた
めに使用(定義)されます。例えば C......lize_copy でコピーするよう定義しておくことで、dup や clone
を再定義する必要がなくなります。
デフォルトの Object#initialize_copy は、 freeze チェックおよび型のチェックを行い self
を返すだけのメソッドです。
initialize_copy と......のメソッドは
自動的に private に設定されます。
@raise TypeError レシーバが freeze されているか、obj のクラスがレシーバ
のクラスと異なる場合に発生します。
@see Object#clone,Object#dup
以下に例として、dup や clone がこのメソッ... -
Object
# instance _ variables -> [Symbol] (6132.0) -
オブジェクトのインスタンス変数名をシンボルの配列として返します。
...列として返します。
//emlist[][ruby]{
obj = Object.new
obj.instance_eval { @foo, @bar = nil }
p obj.instance_variables
#=> [:@foo, :@bar]
//}
@see Object#instance_variable_get, Kernel.#local_variables, Kernel.#global_variables, Module.constants, Module#constants, Module#class_variables... -
WIN32OLE
_ VARIABLE # ole _ type -> String (6119.0) -
変数の型を取得します。
...「Unknown Type nn」(nnはバリアント型を示す数値)の形式の文字列
を返します。
tobj = WIN32OLE_TYPE.new('Microsoft Excel 14.0 Object Library', 'XlSheetType')
variables = tobj.variables
variables.each do |variable|
puts "#{variable.ole_type} #{variable.... -
NameError
# local _ variables -> [Symbol] (6114.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... -
WIN32OLE
_ VARIABLE # ole _ type _ detail -> [String] (6107.0) -
変数の型と属性を取得します。
...2OLE_TYPE.new('Microsoft XML, v5.0', 'tagSTATSTG')
tobj.variables.each do |v|
puts "#{v.ole_type} [#{v.ole_type_detail.join(', ')}] #{v.name}"
end
出力結果
Unknown Type 31 [] pwcsName # => VT_LPWSTR はWIN32OLE::VARIANTで未定義なので変換できない
UI4 [UI4] type
_ULA......EFINED, _FILETIME] mtime
_FILETIME [USERDEFINED, _FILETIME] ctime
_FILETIME [USERDEFINED, _FILETIME] atime
UI4 [UI4] grfMode
UI4 [UI4] grfLocksSupported
GUID [USERDEFINED, GUID] clsid
UI4 [UI4] grfStateBits
UI4 [UI4] reserved
上例のように、WIN32OLE_VARIABLEで取得できる変数あ... -
TracePoint
# binding -> Binding (3013.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 (3013.0) -
発生したイベントによって生成された Binding オブジェクトを返します。
...は 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
//}... -
Module
# constants(inherit = true) -> [Symbol] (49.0) -
そのモジュール(またはクラス)で定義されている定数名の配列を返します。
...。
@param inherit true を指定するとスーパークラスや include したモジュールで
定義された定数が対象にはなります。false を指定した場合 対象にはなりません。
@see Module.constants, Kernel.#local_variables, Kernel.#global_variables, Object#......tance_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 const......ants # => [:BAR]
# 出力に FOO は含まれない
p Module.constants - $clist # => [:BAR, :Bar, :Foo]
class Baz
# Baz は定数を含まない
p constants # => []
# ネストしたクラスでは、外側のクラスで定義... -
Object
# instance _ variable _ defined?(var) -> bool (49.0) -
インスタンス変数 var が定義されていたら真を返します。
...@param var インスタンス変数名を文字列か Symbol で指定します。
//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...