Methods
Class Public methods
new(arg, block_size=500, encoding=nil)
Link
block_size has been deprecated
# File lib/rexml/source.rb, line 161 def initialize(arg, block_size=500, encoding=nil) @er_source = @source = arg @to_utf = false @pending_buffer = nil if encoding super("", encoding) else super(@source.read(3) || "") end if !@to_utf and @buffer.respond_to?(:force_encoding) and @source.respond_to?(:external_encoding) and @source.external_encoding != ::Encoding::UTF_8 @force_utf8 = true else @force_utf8 = false end end
Instance Public methods
consume( pattern )
Link
current_line()
Link
@return the current line in the source
# File lib/rexml/source.rb, line 242 def current_line begin pos = @er_source.pos # The byte position in the source lineno = @er_source.lineno # The XML < position in the source @er_source.rewind line = 0 # The \r\n position in the source begin while @er_source.pos < pos @er_source.readline line += 1 end rescue end rescue IOError pos = -1 line = -1 end [pos, lineno, line] end
empty?()
Link
match( pattern, cons=false )
Link
position()
Link
read()
Link
scan(pattern, cons=false)
Link
# File lib/rexml/source.rb, line 182 def scan(pattern, cons=false) rv = super # You'll notice that this next section is very similar to the same # section in match(), but just a liiittle different. This is # because it is a touch faster to do it this way with scan() # than the way match() does it; enough faster to warrent duplicating # some code if rv.size == 0 until @buffer =~ pattern or @source.nil? begin @buffer << readline rescue Iconv::IllegalSequence raise rescue @source = nil end end rv = super end rv.taint rv end