クラス
- BasicObject (77)
- Class (22)
- ERB (11)
- Object (99)
-
Thread
:: Backtrace :: Location (44) - WIN32OLE (11)
-
WIN32OLE
_ EVENT (11) -
WIN32OLE
_ TYPE (11)
モジュール
- Enumerable (88)
- Forwardable (44)
-
JSON
:: Generator :: GeneratorMethods :: Object (11) - Kernel (11)
キーワード
- ! (11)
- != (11)
- == (11)
- DelegateClass (11)
-
_ dump (11) -
absolute
_ path (11) - allocate (11)
-
base
_ label (11) -
def
_ class (11) -
def
_ delegator (11) -
def
_ instance _ delegator (11) -
default
_ event _ sources (11) - delegate (11)
- handler= (11)
-
initialize
_ copy (11) - inspect (22)
-
instance
_ delegate (11) -
instance
_ eval (22) -
instance
_ exec (11) -
instance
_ variable _ defined? (11) -
instance
_ variable _ get (11) -
marshal
_ dump (11) - max (44)
-
method
_ missing (11) - min (44)
-
ole
_ activex _ initialize (11) -
singleton
_ method (11) -
to
_ json (11) -
to
_ s (22)
検索結果
先頭5件
-
Object
# initialize(*args , &block) -> object (18174.0) -
ユーザ定義クラスのオブジェクト初期化メソッド。
...このメソッドは Class#new から新しく生成されたオブ
ジェクトの初期化のために呼び出されます。他の言語のコンストラクタに相当します。
デフォルトの動作ではなにもしません。
initialize には
Class#new に与えられた引数が......。
initialize という名前のメソッドは自動的に private に設定され
ます。
@param args 初期化時の引数です。
@param block 初期化時のブロック引数です。必須ではありません。
//emlist[][ruby]{
class Foo
def initialize name
puts "initialize Fo......o"
@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
# #<Bar:0x2b68f08 @name="myname", @pass="0500">
//}
@see Class#new... -
Class
# new(*args , &block) -> object (18154.0) -
自身のインスタンスを生成して返します。 このメソッドの引数はブロック引数も含め Object#initialize に渡されます。
...ク引数も含め Object#initialize に渡されます。
new は Class#allocate でインスタンスを生成し、
Object#initialize で初期化を行います。
@param args Object#initialize に渡される引数を指定します。
@param block Object#initialize に渡されるブロッ......クを指定します。
//emlist[例][ruby]{
# Class クラスのインスタンス、C クラスを生成
C = Class.new # => C
# Class クラスのインスタンス、C クラスのインスタンスを生成
C.new # => #<C:0x00005623f8b4e458>
//}... -
Object
# initialize _ copy(obj) -> object (6156.0) -
(拡張ライブラリによる) ユーザ定義クラスのオブジェクトコピーの初期化メソッド。
...し、self のインスタンス変数や特異メソッドは変化しません。
Object#clone, Object#dupの内部で使われています。
initialize_copy は、Ruby インタプリタが知り得ない情報をコピーするた
めに使用(定義)されます。例えば C 言語でクラ......clone
を再定義する必要がなくなります。
デフォルトの Object#initialize_copy は、 freeze チェックおよび型のチェックを行い self
を返すだけのメソッドです。
initialize_copy という名前のメソッドは
自動的に private に設定されます......利用しているかを示します。
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
# ole _ activex _ initialize -> nil (6120.0) -
ActiveXコントロール用の初期化を行います。
...ActiveXコントロール用の初期化を行います。
ole_activex_initializeメソッドは、スクリプト内でActiveXコントロールを利
用できるように、オブジェクトが持つ永続化データを初期化します。
ActiveXコントロール(OCX)は、主にUI用......イ
ンターフェイスを持たない場合に通知します。
obj = WIN32OLE.new("ProgID_or_GUID_of_ActiveX_Control")
obj.ole_activex_initialize
obj.method(...)
なお、生成したOLEオートメーションサーバが永続化データの初期化を... -
Enumerable
# max {|a , b| . . . } -> object | nil (61.0) -
ブロックの評価結果で各要素の大小判定を行い、最大の要素、もしくは最大の n 要素が入った降順の配列を返します。 引数を指定しない形式では要素が存在しなければ nil を返します。 引数を指定する形式では、空の配列を返します。
...:age
def initialize(name, age)
@name = name
@age = age
end
end
people = [
Person.new("sato", 55),
Person.new("sato", 33),
Person.new("sato", 11),
Person.new("suzuki", 55),
Person.new("suzuki", 33),
Person.new("suzuki", 11),
Person.new("tanaka", 55),
Person.new("tanaka",......33),
Person.new("tanaka", 11)
]
# 年齢が最大、名前が最小
people.max { |x, y| (x.age <=> y.age).nonzero? || y.name <=> x.name }
# => #<Person:0x007fc54b0240a0 @name="sato", @age=55>
people.max(2) { |x, y| (x.age <=> y.age).nonzero? || y.name <=> x.name }
# => [#<Person:0x007fc54b0240a0... -
Enumerable
# max(n) {|a , b| . . . } -> Array (61.0) -
ブロックの評価結果で各要素の大小判定を行い、最大の要素、もしくは最大の n 要素が入った降順の配列を返します。 引数を指定しない形式では要素が存在しなければ nil を返します。 引数を指定する形式では、空の配列を返します。
...:age
def initialize(name, age)
@name = name
@age = age
end
end
people = [
Person.new("sato", 55),
Person.new("sato", 33),
Person.new("sato", 11),
Person.new("suzuki", 55),
Person.new("suzuki", 33),
Person.new("suzuki", 11),
Person.new("tanaka", 55),
Person.new("tanaka",......33),
Person.new("tanaka", 11)
]
# 年齢が最大、名前が最小
people.max { |x, y| (x.age <=> y.age).nonzero? || y.name <=> x.name }
# => #<Person:0x007fc54b0240a0 @name="sato", @age=55>
people.max(2) { |x, y| (x.age <=> y.age).nonzero? || y.name <=> x.name }
# => [#<Person:0x007fc54b0240a0... -
Enumerable
# min {|a , b| . . . } -> object | nil (61.0) -
ブロックの評価結果で各要素の大小判定を行い、最小の要素、もしくは最小の n 要素が昇順で入った配列を返します。 引数を指定しない形式では要素が存在しなければ nil を返します。 引数を指定する形式では、空の配列を返します。
...:age
def initialize(name, age)
@name = name
@age = age
end
end
people = [
Person.new("sato", 55),
Person.new("sato", 33),
Person.new("sato", 11),
Person.new("suzuki", 55),
Person.new("suzuki", 33),
Person.new("suzuki", 11),
Person.new("tanaka", 55),
Person.new("tanaka",......33),
Person.new("tanaka", 11)
]
# 年齢が最小、名前が最大
people.min { |x, y| (x.age <=> y.age).nonzero? || y.name <=> x.name }
# => #<Person:0x007fd6f0824190 @name="tanaka", @age=11>
people.min(2) { |x, y| (x.age <=> y.age).nonzero? || y.name <=> x.name }
# => [#<Person:0x007fb5899ef... -
Enumerable
# min(n) {|a , b| . . . } -> Array (61.0) -
ブロックの評価結果で各要素の大小判定を行い、最小の要素、もしくは最小の n 要素が昇順で入った配列を返します。 引数を指定しない形式では要素が存在しなければ nil を返します。 引数を指定する形式では、空の配列を返します。
...:age
def initialize(name, age)
@name = name
@age = age
end
end
people = [
Person.new("sato", 55),
Person.new("sato", 33),
Person.new("sato", 11),
Person.new("suzuki", 55),
Person.new("suzuki", 33),
Person.new("suzuki", 11),
Person.new("tanaka", 55),
Person.new("tanaka",......33),
Person.new("tanaka", 11)
]
# 年齢が最小、名前が最大
people.min { |x, y| (x.age <=> y.age).nonzero? || y.name <=> x.name }
# => #<Person:0x007fd6f0824190 @name="tanaka", @age=11>
people.min(2) { |x, y| (x.age <=> y.age).nonzero? || y.name <=> x.name }
# => [#<Person:0x007fb5899ef... -
WIN32OLE
_ TYPE # default _ event _ sources -> [WIN32OLE _ TYPE] (55.0) -
型が持つソースインターフェイスを取得します。
...たない場合は空配列を返します。
tobj = WIN32OLE_TYPE.new('Microsoft Excel 14.0 Object Library', 'Worksheet')
tobj.default_event_sources.map {|intf| intf.name} #=> ["DocEvents"]
WIN32OLE_EVENT.newでインターフェイス名を指定しない場合は、ここで
返さ......す。
# coding : cp932
require 'win32ole'
type = WIN32OLE_TYPE.new('Microsoft Internet Controls', 'InternetExplorer')
ctl = WIN32OLE.new(type.progid)
source = type.default_event_sources[0]
class WebEvent
def initialize
@completed = false
end
attr_reader :completed
end
sourc......completed = true
end
puts "#{Time.now}: #{m.name} was called"
p arg
end
end
end
evt = WIN32OLE_EVENT.new(ctl)
evt.handler = WebEvent.new
ctl.navigate2 'http://www.ruby-lang.org/'
loop do
break if evt.handler.completed
WIN32OLE_EVENT.message_loop
end
ctl.Quit... -
Object
# inspect -> String (25.0) -
オブジェクトを人間が読める形式に変換した文字列を返します。
...e\"]"
Time.new.inspect # => "2008-03-08 19:43:39 +0900"
//}
inspect メソッドをオーバーライドしなかった場合、クラス名とインスタンス
変数の名前、値の組を元にした文字列を返します。
//emlist[][ruby]{
class Foo
end
Foo.new.inspect......# => "#<Foo:0x0300c868>"
class Bar
def initialize
@bar = 1
end
end
Bar.new.inspect # => "#<Bar:0x0300c868 @bar=1>"
//}
@see Kernel.#p...