Class REXML::Source
In: /home/ser/Work/rexml/rexml/source.rb
Parent: Object
Package diagram
A Source can be searched for patterns, and wraps buffers and other objects and provides consumption of text
Methods
current_line    empty?    encoding    match    new    scan    utf8_enc   
Attributes
buffer  [R] 
line  [R] 
Public Class methods
new(arg)
Constructor @param arg must be a String, and should be a valid XML document
Public Instance methods
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.
match(pattern, consume=false)
empty?()
@return true if the Source is exhausted
current_line()
@return the current line in the source
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>