Class: Rhino::IOReader
- Defined in:
- lib/rhino/context.rb
Overview
:nodoc:
Instance Method Summary collapse
-
#initialize(io) ⇒ IOReader
constructor
A new instance of IOReader.
- #read(charbuffer, offset, length) ⇒ Object
Constructor Details
#initialize(io) ⇒ IOReader
Returns a new instance of IOReader.
121 122 123 |
# File 'lib/rhino/context.rb', line 121 def initialize(io) @io = io end |
Instance Method Details
#read(charbuffer, offset, length) ⇒ Object
125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 |
# File 'lib/rhino/context.rb', line 125 def read(charbuffer, offset, length) begin str = @io.read(length) if str.nil? return -1 else jstring = Java::JavaLang::String.new(str) for i in 0 .. jstring.length - 1 charbuffer[i + offset] = jstring.charAt(i) end return jstring.length end rescue StandardError => e raise Java::JavaIo::IOException.new, "Failed reading from ruby IO object" end end |