70件ヒット
[1-70件を表示]
(0.125秒)
別のキーワード
種類
- インスタンスメソッド (33)
- 文書 (26)
- クラス (11)
クラス
- BasicObject (11)
- Object (11)
-
WIN32OLE
_ EVENT (11)
キーワード
- BasicObject (11)
-
NEWS for Ruby 3
. 0 . 0 (4) - handler= (11)
-
respond
_ to _ missing? (11) -
ruby 1
. 6 feature (11) -
ruby 1
. 8 . 4 feature (11)
検索結果
先頭5件
-
BasicObject
# method _ missing(name , *args) -> object (24225.0) -
呼びだされたメソッドが定義されていなかった時、Rubyインタプリタがこのメソッド を呼び出します。
...ー定義の method_missing メソッドの返り値が未定義メソッドの返り値で
あるかのように見えます。
//emlist[例][ruby]{
class Foo
def initialize(data)
@data = data
end
def method_missing(name, lang)
if name.to_s =~ /\Afind_(\d+)_in\z/
if @data[lan......p @data[lang][$1.to_i]
else
raise "#{lang} unknown"
end
else
super
end
end
end
dic = Foo.new({:English => %w(zero one two), :Esperanto => %w(nulo unu du)})
dic.find_2_in :Esperanto #=> "du"
//}
[注意] このメソッドを override する場合は対象......のメソッド名に対して
Object#respond_to? が真を返すようにしてください。
そのためには、Object#respond_to_missing? も同様に override する必
要があります。
@see Object#respond_to?, Object#respond_to_missing?... -
Object
# respond _ to _ missing?(symbol , include _ private) -> bool (6140.0) -
自身が symbol で表されるメソッドに対し BasicObject#method_missing で反応するつもりならば真を返します。
...ッドに対し
BasicObject#method_missing で反応するつもりならば真を返します。
Object#respond_to? はメソッドが定義されていない場合、
デフォルトでこのメソッドを呼びだし問合せます。
BasicObject#method_missing を override した場合にこ......メソッドも
override されるべきです。
false を返します。
@param symbol メソッド名シンボル
@param include_private private method も含めたい場合に true が渡されます
//emlist[例][ruby]{
class Sample
def method_missing(name, *args)
if name =~ /^to_*/......end
end
def respond_to_missing?(sym, include_private)
(sym =~ /^to_*/) ? true : super
end
end
s = Sample.new
s.to_sample("sample args1", "sample args2")
s.respond_to?(:to_sample) # => true
s.respond_to?(:sample) # => false
//}
@see Object#respond_to?, BasicObject#method_missing... -
BasicObject (6024.0)
-
特殊な用途のために意図的にほとんど何も定義されていないクラスです。 Objectクラスの親にあたります。Ruby 1.9 以降で導入されました。
...=== 性質
BasicObject クラスは Object クラスからほとんどのメソッドを取り除いたクラスです。
Object クラスは様々な便利なメソッドや Kernel から受け継いだ関数的メソッド
を多数有しています。
これに対して、 BasicObject クラ......ます。
例えば、 BasicObject#method_missingを利用して Proxy パターンを実
装する場合にはObject クラスに定義済みのメソッドはプロクシできないという
問題が発生します。このような場合に Object ではなく BasicObject から派生
して......合にだけ BasicObject から派生してください。
=== 例
//emlist[例][ruby]{
class Proxy < BasicObject
def initialize(target)
@target = target
end
def method_missing(message, *args)
@target.__send__(message, *args)
end
end
proxy = Proxy.new("1")
proxy.to_i #=> 1
//}... -
WIN32OLE
_ EVENT # handler=(obj) -> () (3018.0) -
イベント処理を実行するオブジェクトを登録します。
...method_missingが呼ばれます。イベン
ト名は大文字小文字を区別するため、正確な記述が必要です。
@param obj イベントに対応するメソッドを持つオブジェクト。イベント受信を
解除するにはnilを指定します。
class IeHa......ndler
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)......vent=#{id.to_s}, args=#{args.inspect}"
end
end
ie = WIN32OLE.new('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... -
ruby 1
. 6 feature (1302.0) -
ruby 1.6 feature ruby version 1.6 は安定版です。この版での変更はバグ修正がメイン になります。
...ruby 1.6 feature
ruby version 1.6 は安定版です。この版での変更はバグ修正がメイン
になります。
((<stable-snapshot|URL:ftp://ftp.netlab.co.jp/pub/lang/ruby/stable-snapshot.tar.gz>)) は、日々更新される安定版の最新ソースです。
== 1.6.8 (2002-12-24) ->......by 1.6.7 (2002-03-29) [i586-linux]
"ruby-1.6\000-v\000-"
: 2002-03-22 ((<Module/module_eval>))
((<Module/module_eval>)) のブロック内で定数やクラス変数のスコープが
変わることはなくなりました。((<ruby-dev:17876>))
class Foo
FOO = 1......[i586-linux]
"**+"
"\001+"
"\001\000"
"\001+\000"
"*+\000"
=> ruby 1.6.5 (2001-11-01) [i586-linux]
"**+"
"+"
"\001\000"
"+\000"
"*+\000"
: method_missing
以下が Segmentation... -
ruby 1
. 8 . 4 feature (162.0) -
ruby 1.8.4 feature ruby 1.8.4 での ruby 1.8.3 からの変更点です。
...更
# * [api]: 拡張ライブラリ API
# * [lib]: ライブラリ
* レベル
* [bug]: バグ修正
* [new]: 追加されたクラス/メソッドなど
* [compat]: 変更されたクラス/メソッドなど
* 互換性のある変更
* only backward-compatibility
* 影......# => ruby 1.8.4 (2005-12-22) [i686-linux]
-:2: syntax error, unexpected '(', expecting $end
#Tue Nov 1 14:20:11 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
#
# * eval.c (rb_call_super): should call method_missing if super is
# called from Kernel method.......#
# * eval.c (exec_under): frame during eval should preserve external
# information.
: super [bug]
Kernelのメソッド内でsuperを呼んだ時に、存在しないsuperclass
にアクセスしようとするバグの修正。
module Kernel
def foo... -
NEWS for Ruby 3
. 0 . 0 (102.0) -
NEWS for Ruby 3.0.0 このドキュメントは前回リリース以降のバグ修正を除くユーザーに影響のある機能の変更のリストです。
...positional arguments.
Code that resulted in deprecation warnings in Ruby 2.7 will now
result in ArgumentError or different behavior. 14183
* Procs accepting a single rest argument and keywords are no longer
subject to autosplatting. This now matches the behavior of Procs
accepting......list[][ruby]{
pr = proc{|*a, **kw| [a, kw]}
pr.call([1])
# 2.7 => [[1], {}]
# 3.0 => [[[1]], {}]
pr.call([1, {a: 1}])
# 2.7 => [[1], {:a=>1}] # and deprecation warning
# 3.0 => a=>1}, {}]
//}
* Arguments forwarding (`...`) now supports leading arguments.
16378
//emlist{
def method_missing(......since Ruby 2.7.2).
Turn them on with `-W:deprecated` (or with `-w` to show other warnings too).
16345
* `$SAFE` and `$KCODE` are now normal global variables with no special behavior.
C-API methods related to `$SAFE` have been removed.
16131 17136
* yield in singleton class defini...