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.
301 302 303 |
# File 'lib/rhino/context.rb', line 301 def initialize(io) @io = io end |
Instance Method Details
#read(buffer, offset, length) ⇒ Object
implement int Reader#read(char[] buffer, int offset, int length)
306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 |
# File 'lib/rhino/context.rb', line 306 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 |