Class: Nokogiri::Streaming::IOWrapper

Inherits:
Object
  • Object
show all
Defined in:
lib/nokogiri/streaming/reader.rb

Overview

IO wrapper which traps stream exceptions. This works around bug in Nokogiri’s SAX code, which seems to ignore exceptions entirely.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(source) ⇒ IOWrapper

Returns a new instance of IOWrapper.



116
117
118
# File 'lib/nokogiri/streaming/reader.rb', line 116

def initialize(source)
  @source = source
end

Instance Attribute Details

#exceptionObject (readonly)

Returns the value of attribute exception.



133
134
135
# File 'lib/nokogiri/streaming/reader.rb', line 133

def exception
  @exception
end

Instance Method Details

#closeObject



129
130
131
# File 'lib/nokogiri/streaming/reader.rb', line 129

def close
  @stream.close
end

#read(length = nil) ⇒ Object



120
121
122
123
124
125
126
127
# File 'lib/nokogiri/streaming/reader.rb', line 120

def read(length = nil)
  begin
    return @source.read(length)
  rescue => e
    @exception = e
    raise
  end
end