Method: REXML::IOSource#current_line

Defined in:
lib/extensions/rexml/rexml/source.rb,
lib/extensions/rhoxml/rexml/source.rb

#current_lineObject

Returns the current line in the source.

Returns:

  • the current line in the source



236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
# File 'lib/extensions/rexml/rexml/source.rb', line 236

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