class Thrift::MemoryBufferTransport

Constants

GARBAGE_BUFFER_SIZE

Public Class Methods

new(buffer = nil) click to toggle source

If you pass a string to this, you should dup that string unless you want it to be modified by read and write

# File build/evernote-mode-6YHuyP/evernote-mode-0.41/ruby/thrift/transport/memory_buffer_transport.rb, line 29
def initialize(buffer = nil)
  @buf = buffer || ''
  @index = 0
end

Public Instance Methods

available() click to toggle source
# File build/evernote-mode-6YHuyP/evernote-mode-0.41/ruby/thrift/transport/memory_buffer_transport.rb, line 54
def available
  @buf.length - @index
end
close() click to toggle source
# File build/evernote-mode-6YHuyP/evernote-mode-0.41/ruby/thrift/transport/memory_buffer_transport.rb, line 41
def close
end
flush() click to toggle source
# File build/evernote-mode-6YHuyP/evernote-mode-0.41/ruby/thrift/transport/memory_buffer_transport.rb, line 76
def flush
end
inspect_buffer() click to toggle source
# File build/evernote-mode-6YHuyP/evernote-mode-0.41/ruby/thrift/transport/memory_buffer_transport.rb, line 79
def inspect_buffer
  out = []
  for idx in 0...(@buf.size)
    # if idx != 0
    #   out << " "
    # end
  
    if idx == @index
      out << ">"
    end
  
    out << @buf[idx].ord.to_s(16)
  end
  out.join(" ")
end
open() click to toggle source
# File build/evernote-mode-6YHuyP/evernote-mode-0.41/ruby/thrift/transport/memory_buffer_transport.rb, line 38
def open
end
open?() click to toggle source
# File build/evernote-mode-6YHuyP/evernote-mode-0.41/ruby/thrift/transport/memory_buffer_transport.rb, line 34
def open?
  return true
end
peek() click to toggle source
# File build/evernote-mode-6YHuyP/evernote-mode-0.41/ruby/thrift/transport/memory_buffer_transport.rb, line 44
def peek
  @index < @buf.size
end
read(len) click to toggle source
# File build/evernote-mode-6YHuyP/evernote-mode-0.41/ruby/thrift/transport/memory_buffer_transport.rb, line 58
def read(len)
  data = @buf.slice(@index, len)
  @index += len
  @index = @buf.size if @index > @buf.size
  if @index >= GARBAGE_BUFFER_SIZE
    @buf = @buf.slice(@index..-1)
    @index = 0
  end
  if data.size < len
    raise EOFError, "Not enough bytes remain in buffer"
  end
  data
end
reset_buffer(new_buf = '') click to toggle source

this method does not use the passed object directly but copies it

# File build/evernote-mode-6YHuyP/evernote-mode-0.41/ruby/thrift/transport/memory_buffer_transport.rb, line 49
def reset_buffer(new_buf = '')
  @buf.replace new_buf
  @index = 0
end
write(wbuf) click to toggle source
# File build/evernote-mode-6YHuyP/evernote-mode-0.41/ruby/thrift/transport/memory_buffer_transport.rb, line 72
def write(wbuf)
  @buf << wbuf
end