Class: Rhino::IOReader
Overview
:nodoc:
Instance Method Summary collapse
-
#initialize(io) ⇒ IOReader
constructor
A new instance of IOReader.
-
#read(buffer, offset, length) ⇒ Object
implement int Reader#read(char[] buffer, int offset, int length).
Constructor Details
#initialize(io) ⇒ IOReader
Returns a new instance of IOReader.
239 240 241 |
# File 'lib/rhino/context.rb', line 239 def initialize(io) @io = io end |
Instance Method Details
#read(buffer, offset, length) ⇒ Object
implement int Reader#read(char[] buffer, int offset, int length)
244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 |
# File 'lib/rhino/context.rb', line 244 def read(buffer, offset, length) str = nil begin str = @io.read(length) rescue StandardError => e raise java.io.IOException.new("failed reading from ruby IO object") end if str.nil? return -1 else jstr = str.to_java for i in 0 .. jstr.length - 1 buffer[i + offset] = jstr.charAt(i) end return jstr.length end end |