class Koara::Io::StringReader
Public Class Methods
new(text='')
click to toggle source
# File lib/koara/io/stringreader.rb, line 5 def initialize(text='') @text = text @index = 0 end
Public Instance Methods
read(buffer, offset, length)
click to toggle source
# File lib/koara/io/stringreader.rb, line 10 def read(buffer, offset, length) slice = @text.slice(@index, @text.length) if @text != '' && slice && slice.length > 0 characters_read = 0 0.upto(length - 1) do |i| c = @text.slice(@index + i) if c buffer[offset + i] = c characters_read += 1 end end @index += length return characters_read end -1 end