| Class REXML::Source |
|
A Source can be searched for patterns, and wraps buffers and other objects and provides consumption of text
Sourceはパターンで検索することができます。そして、bufferと他のオ ブジェクトとテキストの消費をもたらすものを包みます。
| Methods |
| Attributes |
| :buffer | [R] | The current buffer (what we're going to read next) 現在のバッファ(私達が次に読もうとしているもの) |
| :encoding | [R] | |
| :line | [R] | The line number of the last consumed text 最後に消費した行番号 |
| Public Class methods |
| new(arg) |
Constructor
@param arg must be a String, and should be a valid XML document
コンストラクタ
@パラメータargはStringで無ければいけません。そして、妥当なXML文 書であるべきです。
| encoding_val( enc ) |
| val_encoding( enc ) |
| Public Instance methods |
| encoding=(enc) |
| scan(pattern, consume=false) |
Scans the source for a given pattern. Note, that this is not your usual scan() method. For one thing, the pattern argument has some requirements; for another, the source can be consumed. You can easily confuse this method. Originally, the patterns were easier to construct and this method more robust, because this method generated search regexes on the fly; however, this was computationally expensive and slowed down the entire REXML package considerably, since this is by far the most commonly called method.
@param pattern must be a Regexp, and must be in the form of /^\s*(#{your pattern, with no groups})(.*)/. The first group will be returned; the second group is used if the consume flag is set.
@param consume if true, the pattern returned will be consumed, leaving everything after it in the Source.
@return the pattern, if found, or nil if the Source is empty or the pattern is not found.
与えられたpatternでソースを調べます。これはあなたのいつもの scan()メソッドではないことを注意して下さい。例えば、引数pattern にはいくつか必要条件があります。;別の例では、ソースは消費される ことができます。あなたは簡単にこのメソッドを混乱させることができ ます。元々patternは組み立てるのが簡単でした。そして、もっと頑丈 でした。なぜならば、このメソッドは検索する正規表現を大急ぎで生み 出していたからです。;しかし、これは贅沢な計算をし、郡を抜いてもっ とも広く呼ばれているメソッドだったので、REXMLパッケージ全体をかな りスピードダウンしました。
@パラメータpatternはRegrepでなければいけません。そして、/^\s(# {グループ無しのパターン})(.*)/という形式でなければいけません。最 初のグループが返されるでしょう。;二番目のグループは、もし、 consumeフラグが設定されていれば使われます。
@もしパラメータconsumeがtrueなら、返されるpatternはSourceの中の patternの後は全て残されたまま、消費されているでしょう。
@もし見つかれば、patternを返します。Sourceが空か、patternが見つ からなかったらnilを返します。
| match(pattern, consume=false) |
| empty?() |
| current_line() |
@return the current line in the source
ソースの現在行を返します。
| check_encoding(str) |
Taken from code contributed by Ernest Ellingson <erne@powernav.com>
| utf8_enc(str) |
Taken from code contributed by Ernest Ellingson <erne@powernav.com>
| asc(str) |
| utf16(str) |
| unile(str) |
| utf8(str) |