132件ヒット
[1-100件を表示]
(0.071秒)
別のキーワード
クラス
- BasicObject (24)
- Object (36)
-
Thread
:: Backtrace :: Location (48) -
WIN32OLE
_ EVENT (12) -
WIN32OLE
_ TYPE (12)
キーワード
- ! (12)
- != (12)
-
absolute
_ path (12) -
base
_ label (12) -
default
_ event _ sources (12) - handler= (12)
-
initialize
_ copy (12) - inspect (12)
-
to
_ s (24)
検索結果
先頭5件
-
Object
# initialize(*args , &block) -> object (18274.0) -
ユーザ定義クラスのオブジェクト初期化メソッド。
...トの動作ではなにもしません。
initialize には
Class#new に与えられた引数がそのまま渡されます。
サブクラスではこのメソッドを必要に応じて再定義されること
が期待されています。
initialize という名前のメソッドは自動......//emlist[][ruby]{
class Foo
def initialize name
puts "initialize Foo"
@name = name
end
end
class Bar < Foo
def initialize name, pass
puts "initialize Bar"
super name
@pass = pass
end
end
it = Bar.new('myname','0500')
p it
#=> initialize Bar
# initialize Foo
# #<Ba... -
Object
# initialize _ copy(obj) -> object (6316.0) -
(拡張ライブラリによる) ユーザ定義クラスのオブジェクトコピーの初期化メソッド。
...は変化しません。
デフォルトでは、Object#clone の内部で Object#initialize_clone から、
また Object#dup の内部で Object#initialize_dup から呼ばれます。
initialize_copy は、Ruby インタプリタが知り得ない情報をコピーするた
めに使用(定義)...... initialize_copy でコピーするよう定義しておくことで、dup や clone
を再定義する必要がなくなります。
デフォルトの Object#initialize_copy は、 freeze チェックおよび型のチェックを行い self
を返すだけのメソッドです。
initialize_cop......利用しているかを示します。
obj.dup は、新たに生成したオブジェクトに対して
initialize_copy を呼び
//emlist[][ruby]{
obj2 = obj.class.allocate
obj2.initialize_copy(obj)
//}
obj2 に対してさらに obj の汚染状態、インスタンス変数、ファイナラ......利用しているかを示します。
obj.dup は、新たに生成したオブジェクトに対して
initialize_copy を呼び
//emlist[][ruby]{
obj2 = obj.class.allocate
obj2.initialize_copy(obj)
//}
obj2 に対してさらに obj のインスタンス変数、ファイナライザを
コ... -
WIN32OLE
_ TYPE # default _ event _ sources -> [WIN32OLE _ TYPE] (479.0) -
型が持つソースインターフェイスを取得します。
...nt
def initialize
@completed = false
end
attr_reader :completed
end
source.ole_methods.each do |m|
WebEvent.module_eval do
define_method("on#{m.name}") do |*arg|
if arg[0] == "ページが表示されました"
@completed = true
end
puts "#{Time.......w.ruby-lang.org/'
loop do
break if evt.handler.completed
WIN32OLE_EVENT.message_loop
end
ctl.Quit
このプログラムを実行するとWindows7のIE8環境では以下のような出力を得られ
ます。
2010-10-06 22:33:54 +0900: PropertyChange was called
["{265b75c1-4158-11d0-90......f6-00c04fd497ea}"]
2010-10-06 22:33:54 +0900: BeforeNavigate2 was called
[#<WIN32OLE:0x9d08f0>, "http://www.ruby-lang.org/", 0, "", nil, "", false]
2010-10-06 22:33:54 +0900: DownloadBegin was called
[]
2010-10-06 22:33:54 +0900: PropertyChange was called
["{D0FCA420-D3F5-11CF-B211-00AA004AE83... -
BasicObject
# ! -> bool (161.0) -
オブジェクトを真偽値として評価し、その論理否定を返します。
...ドを再定義しても Ruby の制御式において nil や false 以外が偽として
扱われることはありません。
@return オブジェクトが偽であれば真、さもなくば偽
//emlist[例][ruby]{
class NegationRecorder < BasicObject
def initialize
@count = 0
end......r = NegationRecorder.new
!recorder
!!!!!!!recorder
puts 'hoge' if !recorder
puts recorder.count #=> 3
//}
//emlist[例][ruby]{
class AnotherFalse < BasicObject
def !
true
end
end
another_false = AnotherFalse.new
# another_falseは*真*
puts "another false is a truth" if another_false
#=>... -
WIN32OLE
_ EVENT # handler=(obj) -> () (137.0) -
イベント処理を実行するオブジェクトを登録します。
...def initialize
@completed = false
end
attr_reader :completed
def onDocumentComplete(disp, uri)
disp.document.getElementsByTagName('a').each do |e|
puts "#{e.innerHTML}=#{e.href}"
end
@completed = true
end
def method_missing(id, *args)
puts "e......'InternetExplorer.Application.1')
event = WIN32OLE_EVENT.new(ie, 'DWebBrowserEvents2')
event.handler = IeHandler.new
ie.Navigate2 'http://www.ruby-lang.org/ja/'
loop do
break if event.handler.completed
WIN32OLE_EVENT.message_loop
end
ie.Quit
WIN32OLE_EVENT#on_eventなどの呼... -
Object
# to _ s -> String (131.0) -
オブジェクトの文字列表現を返します。
...ドを使って文字列に変換し
ます。
//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.#Str... -
Thread
:: Backtrace :: Location # base _ label -> String (131.0) -
self が表すフレームの基本ラベルを返します。通常、 Thread::Backtrace::Location#label から修飾を取り除いたもので構成 されます。
...ので構成
されます。
//emlist[例][ruby]{
# foo.rb
class Foo
attr_accessor :locations
def initialize(skip)
@locations = caller_locations(skip)
end
end
Foo.new(0..2).locations.map do |call|
puts call.base_label
end
# => initialize
# new
# <main>
//}
@see Thread::Backtrace::Loc... -
Thread
:: Backtrace :: Location # inspect -> String (131.0) -
Thread::Backtrace::Location#to_s の結果を人間が読みやすいような文 字列に変換したオブジェクトを返します。
...トを返します。
//emlist[例][ruby]{
# foo.rb
class Foo
attr_accessor :locations
def initialize(skip)
@locations = caller_locations(skip)
end
end
Foo.new(0..2).locations.map do |call|
puts call.inspect
end
# => "path/to/foo.rb:5:in `initialize'"
# "path/to/foo.rb:9:in `new'"
# "... -
Thread
:: Backtrace :: Location # to _ s -> String (131.0) -
self が表すフレームを Kernel.#caller と同じ表現にした文字列を返し ます。
...列を返し
ます。
//emlist[例][ruby]{
# foo.rb
class Foo
attr_accessor :locations
def initialize(skip)
@locations = caller_locations(skip)
end
end
Foo.new(0..2).locations.map do |call|
puts call.to_s
end
# => path/to/foo.rb:5:in `initialize'
# path/to/foo.rb:9:in `new'
# path/to...