101件ヒット
[1-100件を表示]
(0.029秒)
別のキーワード
種類
- インスタンスメソッド (36)
- 文書 (29)
- ライブラリ (24)
- クラス (12)
クラス
- BasicObject (12)
- Object (12)
-
WIN32OLE
_ EVENT (12)
キーワード
- BasicObject (12)
-
NEWS for Ruby 3
. 0 . 0 (5) - handler= (12)
-
respond
_ to _ missing? (12) -
rexml
/ parsers / sax2parser (12) -
rexml
/ parsers / streamparser (12) -
ruby 1
. 6 feature (12) -
ruby 1
. 8 . 4 feature (12)
検索結果
先頭5件
-
BasicObject
# method _ missing(name , *args) -> object (18143.0) -
呼びだされたメソッドが定義されていなかった時、Rubyインタプリタがこのメソッド を呼び出します。
...数です。
@return ユーザー定義の 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[lang]
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"
//}
[注意] このメソッド... -
ruby 1
. 6 feature (312.0) -
ruby 1.6 feature ruby version 1.6 は安定版です。この版での変更はバグ修正がメイン になります。
...ーになっていました。
((<ruby-dev:17155>))
open("|-","r+") {|f|
if f
f.dup.close_write
else
sleep 1
end
}
=> ruby 1.6.7 (2002-03-01) [i586-linux]
-:3:in `close_write': closing non-duplex IO for writing (IOError)
from -:3......トで 2 回シグナルを送らないと終了しない不具合が修正さ
れました。((<ruby-bugs-ja:PR#223>))
trap(:TERM, "EXIT")
END{
puts "exit"
}
Thread.start { Thread.stop }
sleep
: 2002-04-17: Regexp#inspect
((<ruby-bugs-ja:PR#222>))
p %r{\/}......=> ruby 1.6.5 (2001-11-01) [i586-linux]
"**+"
"+"
"\001\000"
"+\000"
"*+\000"
: method_missing
以下が Segmentation Fault していました。((<ruby-dev:14942>))
Module.constants.each {|c|
c = eval c... -
rexml
/ parsers / sax2parser (66.0) -
SAX2 と同等の API を持つストリーム式の XML パーサ。
...omment here--> &bar;
</root>
EOS
class Listener
#include REXML::SAX2Listener
def method_missing(name, *args)
p [name, *args]
end
def respond_to_missing?(name, include_private)
name != :call
end
end
parser = REXML::Parsers::SAX2Parser.new(xml)
parser.listen(Listener.new)
parser.pa......_element, "http://example.org/bar", "b", "bar:b", {}]
# >> [:progress, 683]
# >> [:end_element, "http://example.org/bar", "b", "bar:b"]
# >> [:progress, 683]
# >> [:characters, "\n "]
# >> [:progress, 683]
# >> [:end_element, "http://example.org/default", "a", "a"]
# >> [:progress, 683]
# >> [:char......barbarbarbar\n"]
# >> [:progress, 683]
# >> [:end_element, "http://example.org/default", "root", "root"]
# >> [:end_prefix_mapping, nil]
# >> [:end_prefix_mapping, "foo"]
# >> [:end_prefix_mapping, "bar"]
# >> [:progress, 683]
# >> [:characters, "\n"]
# >> [:progress, 683]
# >> [:end_document]
//}... -
rexml
/ parsers / streamparser (66.0) -
ストリーム式の XML パーサ。
...ener
include REXML::StreamListener
def initialize
@events = []
end
def text(text)
@events << "text[#{text}]"
end
def tag_start(name, attrs)
@events << "tag_start[#{name}]"
end
attr_reader :events
end
xml = <<EOS
<members>
<member name="apple" color="red">
<comme......'2' att='<'/>
&& <!-- comment here--> &bar;
</root>
EOS
class Listener
def method_missing(name, *args)
p [name, *args]
end
def respond_to_missing?(sym, include_private)
true
end
end
REXML::Parsers::StreamParser.new(xml, Listener.new).parse
# >> [:xmldecl, "1.0", "UTF-8......]]
# >> [:doctype_end]
# >> [:text, "\n"]
# >> [:tag_start, "root", {"xmlns:foo"=>"http://example.org/foo", "xmlns:bar"=>"http://example.org/bar"}]
# >> [:cdata, "cdata is here"]
# >> [:text, "\n "]
# >> [:tag_start, "a", {"foo:att"=>"1", "bar:att"=>"2", "att"=>"<"}]
# >> [:tag_end, "a"]
# >> [:tex... -
ruby 1
. 8 . 4 feature (60.0) -
ruby 1.8.4 feature ruby 1.8.4 での ruby 1.8.3 からの変更点です。
...適合する文字列を厳密にした。((<ruby-core:03573>)),((<ruby-dev:27478>))
1) alias :"foo" :"bar"
def bar; p "bar"; end
alias :"foo" :"bar"
foo
# => ruby 1.8.4 (2005-12-22) [i686-linux]
-:2: syntax error, unexpecte......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):......在しないsuperclass
にアクセスしようとするバグの修正。
module Kernel
def foo
super
end
end
foo
# => ruby 1.8.3 (2005-09-21) [i686-linux]
-:3:in `foo': method `foo' called on terminated object (0xb... -
Object
# respond _ to _ missing?(symbol , include _ private) -> bool (58.0) -
自身が symbol で表されるメソッドに対し BasicObject#method_missing で反応するつもりならば真を返します。
...ソッドに対し
BasicObject#method_missing で反応するつもりならば真を返します。
Object#respond_to? はメソッドが定義されていない場合、
デフォルトでこのメソッドを呼びだし問合せます。
BasicObject#method_missing を override した場合に......class Sample
def method_missing(name, *args)
if name =~ /^to_*/
[name, *args] # => [:to_sample, "sample args1", "sample args2"]
return
else
super
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... -
NEWS for Ruby 3
. 0 . 0 (54.0) -
NEWS for Ruby 3.0.0 このドキュメントは前回リリース以降のバグ修正を除くユーザーに影響のある機能の変更のリストです。
...warning
# 3.0 => a=>1}, {}]
//}
* Arguments forwarding (`...`) now supports leading arguments.
16378
//emlist{
def method_missing(meth, ...)
send(:"do_#{meth}", ...)
end
//}
* Pattern matching (`case/in`) is no longer experimental. 17260
* One-line pattern matching is redesigned......."f", 3]
in [*pre, String => x, String => y, *post]
p pre #=> ["a", 1]
p x #=> "b"
p y #=> "c"
p post #=> [2, "d", "e", "f", 3]
end
//}
* Endless method definition is added. [EXPERIMENTAL]
16746
//emlist{
def square(x) = x * x
//}
* Interpolated String literals are no long......Module
* Module#include and Module#prepend now affect classes and modules that have already included or prepended the receiver, mirroring the behavior if the arguments were included in the receiver before the other modules and classes included or prepended the receiver. 9573
* Module#public,... -
WIN32OLE
_ EVENT # handler=(obj) -> () (48.0) -
イベント処理を実行するオブジェクトを登録します。
...ンドラはイベント名に「on」を前置します。もし、イベントに対応
するonメソッドが実装されていなければmethod_missingが呼ばれます。イベン
ト名は大文字小文字を区別するため、正確な記述が必要です。
@param obj イベントに......tialize
@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 "event=#{......t}"
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_EVENT.message_loop
end
ie.Quit... -
BasicObject (30.0)
-
特殊な用途のために意図的にほとんど何も定義されていないクラスです。 Objectクラスの親にあたります。Ruby 1.9 以降で導入されました。
...スを定義する際には Object クラスは持っているメソッドが多すぎる
場合があります。
例えば、 BasicObject#method_missingを利用して Proxy パターンを実
装する場合にはObject クラスに定義済みのメソッドはプロクシできないという......合にだけ 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
//}...