別のキーワード
ライブラリ
- ビルトイン (169)
- forwardable (22)
- json (11)
- win32ole (11)
クラス
-
JSON
:: State (11) - Method (40)
- Module (11)
- Regexp (22)
- String (33)
- Thread (11)
-
WIN32OLE
_ TYPE (11)
モジュール
- Forwardable (22)
- Kernel (33)
-
RubyVM
:: AbstractSyntaxTree (8)
キーワード
-
1
. 6 . 8から1 . 8 . 0への変更点(まとめ) (11) - === (7)
-
NEWS for Ruby 2
. 7 . 0 (5) -
NEWS for Ruby 3
. 1 . 0 (3) - Numeric (11)
- Rubyで使われる記号の意味(正規表現の複雑な記号は除く) (11)
- call (22)
- caller (33)
-
def
_ delegator (11) -
def
_ instance _ delegator (11) -
default
_ event _ sources (11) - encode (33)
- match (22)
- of (8)
-
rexml
/ parsers / sax2parser (11) -
rexml
/ parsers / streamparser (11) -
ruby 1
. 6 feature (11) -
ruby 1
. 8 . 3 feature (11) -
ruby 1
. 9 feature (11) -
undef
_ method (11) -
webrick
/ cgi (11) - クラス/メソッドの定義 (11)
検索結果
先頭5件
-
Forwardable
# def _ instance _ delegator(accessor , method , ali = method) -> () (222.0) -
メソッドの委譲先を設定します。
...。
@param accessor 委譲先のオブジェクト
@param method 委譲先のメソッド
@param ali 委譲元のメソッド
委譲元のオブジェクトで ali が呼び出された場合に、
委譲先のオブジェクトの method へ処理が委譲されるようになります。
委......require 'forwardable'
class MyQueue
extend Forwardable
attr_reader :queue
def initialize
@queue = []
end
def_delegator :@queue, :push, :mypush
end
q = MyQueue.new
q.mypush 42
q.queue # => [42]
q.push 23 # => NoMethodError
@see Forwardable#def_delegators... -
クラス/メソッドの定義 (212.0)
-
クラス/メソッドの定義 * クラス/メソッドの定義: * class * singleton_class * module * method * operator * nest_method * eval_method * singleton_method * class_method * limit * 定義に関する操作: * alias * undef * defined
...定義
* クラス/メソッドの定義:
* class
* singleton_class
* module
* method
* operator
* nest_method
* eval_method
* singleton_method
* class_method
* limit
* 定義に関する操作:
* alias
* undef
* defined
===[a:class] クラ......の追加になります。
ただし、元のクラスと異なるスーパークラスを指定すると TypeError が発生します。
//emlist[][ruby]{
class Foo < Array
def foo
end
end
# 定義を追加(スーパークラス Array を明示的に指定しても同じ)
class Foo
def bar......関係などの機能的な関連はまったくありません。
//emlist[][ruby]{
class Foo
class Bar
end
end
//}
クラス Foo が既に定義されていれば、以下の書き方もできます。
//emlist[][ruby]{
class Foo
end
class Foo::Bar
end
//}
クラスのネストは、意... -
ruby 1
. 6 feature (138.0) -
ruby 1.6 feature ruby version 1.6 は安定版です。この版での変更はバグ修正がメイン になります。
...範囲外の文字列を指定したときに例外を返す場合がありましたが、常に nil
を返すようになりました。(String#[]やString#slice と同じ結果を返すと
いうことです)
p "foo".slice!("bar") # <- 以前からこちらは nil を返してい......ymlink("foo", "bar")
p Dir.glob("bar")
=> ruby 1.6.7 (2002-03-01) [i586-linux]
[]
=> ruby 1.6.7 (2002-08-01) [i586-linux]
["bar"]
: 2002-06-13 Hash[]
Hash[] で、キーとなる文字列を dup & freeze していませんでした。
a = "k......roc#yield を呼んでいました。
((<ruby-dev:16178>))
Marshal.load(Marshal.dump('foo'), proc {|o| p o})
=> -:1:in `load': undefined method `yield' for #<Proc:0x401b1b30> (NameError)
from -:1
ruby 1.6.7 (2002-03-01) [i586-linux]
=> ruby 1.6.6 (2001-12-26) [i586... -
ruby 1
. 9 feature (78.0) -
ruby 1.9 feature ruby version 1.9.0 は開発版です。 以下にあげる機能は将来削除されたり互換性のない仕様変更がなされるかもしれません。 1.9.1 以降は安定版です。 バグ修正がメインになります。
...: Hash#identical?
=== 2006-08-31
: Array#shuffle
: Array#shuffle!
追加
=== 2006-07-26
: __send
: __send!
追加
: invoke_method
: invoke_functional_method
削除
=== 2006-07-21
: Module#attr
オプショナル引数の assignable がなくなり、attr_reader 相当になりま......6-06-17
: BasicObject#invoke_method
: BasicObject#invoke_functional_method
追加
((<ruby-talk:197512>))
=== 2006-06-13
: IPsocket
: TCPsocket
: SOCKSsocket
: TCPserver
: UDPsocket
: UNIXsocket
: UNIXserver
削除
=== 2006-06-11
: __callee__ [new]
: __method__ [new]
((<URL:http://www......1文字の String を返すようになりました
: sprintf の %c が 1文字の String を受け付けるようになりました
: String#[]= が右辺の整数を受け付けなくなりました
: String#chr という先頭の1文字を返すメソッドが追加されました
: I... -
NEWS for Ruby 2
. 7 . 0 (48.0) -
NEWS for Ruby 2.7.0 このドキュメントは前回リリース以降のバグ修正を除くユーザーに影響のある機能の変更のリストです。
...て導入されました。 14912
//emlist[][ruby]{
case [0, [1, 2, 3]]
in [a, [b, *c]]
p a #=> 0
p b #=> 1
p c #=> [2, 3]
end
//}
//emlist[][ruby]{
case {a: 0, b: 1}
in {a: 0, x: 1}
:unreachable
in {a: 0, b: var}
p var #=> 1
end
//}
//emlist[][ruby]{
case -1
in 0 then :unreachable
in 1......lat演算子(**)を足すことで警告を回避できます。
このように書けばRuby 3でも同じ意味で動きます。
//emlist[][ruby]{
def foo(key: 42); end; foo({key: 42}) # warned
def foo(**kw); end; foo({key: 42}) # warned
def foo(key: 42); end; foo(**{key: 42}) # O......は Ruby 3.0 では verbose モードでなくても表示され、Ruby 3.2 で削除される
予定です。 16131
* Object#methodとModule#instance_methodがrefinementsを考慮するようになりました。 15373
=== コマンドラインオプション
==== 警告オプション... -
NEWS for Ruby 3
. 1 . 0 (42.0) -
NEWS for Ruby 3.1.0 このドキュメントは前回リリース以降のバグ修正を除くユーザーに影響のある機能の変更のリストです。
...mlist[][ruby]{
foo[0] = bar
//}
* 次の評価順序になります。
//emlist{
1. `foo`
2. `bar`
3. `[]=` called on the result of `foo`
//}
* Ruby 3.1.0より前は、多重代入の評価順序が上記のようではありませんでした。このコードでは、
//emlist[][rub......`foo`
4. `[]=` called on the result of `foo`
5. `bar`
6. `baz=` called on the result of `bar`
//}
* Ruby 3.1.0から単一代入と評価順序が一致するようになり、左が右より先に評価されます。
//emlist{
1. `foo`
2. `bar`
3. `a`
4. `b`
5. `[]=` called on......* MatchData#match_length が追加されました。 18172
* Method / UnboundMethod
* 新規メソッド
* Method#public?, Method#private?, Method#protected?, UnboundMethod#public?, UnboundMethod#private?, UnboundMethod#protected? が追加されました。 11689
* Module
*... -
ruby 1
. 8 . 3 feature (30.0) -
ruby 1.8.3 feature *((<ruby 1.8 feature>)) *((<ruby 1.8.2 feature>))
...eUtils.options [lib] [new]
: FileUtils.have_option? [lib] [new]
: FileUtils.options_of [lib] [new]
: FileUtils.collect_method [lib] [new]
追加。
: FileUtils.rm_r [lib] [compat]
: FileUtils.rm_rf [lib] [compat]
: FileUtils.cd [lib] [compat]
: FileUtils.cp_r......"
$ ruby-1.8.3 mthd_taint.rb
0
mthd_taint.rb:11:in `foo': calling insecure method: foo (SecurityError)
from mthd_taint.rb:11
=== 2005-09-09
: String#* [ruby] [compat]
: String#[] [ruby] [compat]
空文字にも taint が伝播するようになりました。((<ruby-......を呼んでしまうと空になるバグを修正しました。
$ ruby-1.8.2 -e '
d = Dir.new("/")
d.entries
p d.entries
'
[]
$ ruby-1.8.3 -e '
d = Dir.new("/")
d.entries
p d.entries
'
[".", "..", "dev", "home", "proc", "var", "tmp", "etc", "... -
WIN32OLE
_ TYPE # default _ event _ sources -> [WIN32OLE _ TYPE] (24.0) -
型が持つソースインターフェイスを取得します。
...ources[0]
class WebEvent
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
e......avigate2 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-00AA004AE837}"]
2010-10-06 22:33:54 +0900: CommandStateChange wa......as called
[10000, 10000]
2010-10-06 22:33:54 +0900: ProgressChange was called
[-1, 10000]
2010-10-06 22:33:54 +0900: DownloadComplete was called
[]
2010-10-06 22:33:54 +0900: ProgressChange was called
[10000, 10000]
2010-10-06 22:33:54 +0900: DocumentComplete was called
[#<WIN32OLE:0x438a2f... -
rexml
/ parsers / sax2parser (24.0) -
SAX2 と同等の API を持つストリーム式の XML パーサ。
...サよりは高機能です。
//emlist[][ruby]{
require 'rexml/parsers/sax2parser'
require 'rexml/sax2listener'
parser = REXML::Parsers::SAX2Parser.new(<<XML)
<root n="0">
<a n="1">111</a>
<b n="2">222</b>
<a n="3">333</a>
</root>
XML
elements = []
parser.listen(:start_element){|uri, local......name, qname, attrs|
elements << [qname, attrs]
}
as = []
parser.listen(:start_element, ["a"]){|uri, localname, qname, attrs|
as << [qname, attrs]
}
texts = []
parser.listen(:characters, ["a"]){|c| texts << c }
parser.parse
elements # => [["root", {"n"=>"0"}], ["a", {"n"=>"1"}], ["b", {"n"=>"2"}]......bar:att='2' att='<'>
<bar:b />
</a>
&& <!-- comment 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::Pars... -
Kernel
. # caller(range) -> [String] | nil (18.0) -
start 段上の呼び出し元の情報を $@ の形式のバックトレース(文字列の配列)として返します。
...# []
# nil
//}
以下の関数は、caller の要素から [ファイル名, 行番号, メソッド名]
を取り出して返します。
//emlist[例][ruby]{
def parse_caller(at)
if /^(.+?):(\d+)(?::in `(.*)')?/ =~ at
file = $1
line = $2.to_i
method = $3
[file, line, method... -
Kernel
. # caller(start = 1) -> [String] | nil (18.0) -
start 段上の呼び出し元の情報を $@ の形式のバックトレース(文字列の配列)として返します。
...# []
# nil
//}
以下の関数は、caller の要素から [ファイル名, 行番号, メソッド名]
を取り出して返します。
//emlist[例][ruby]{
def parse_caller(at)
if /^(.+?):(\d+)(?::in `(.*)')?/ =~ at
file = $1
line = $2.to_i
method = $3
[file, line, method...