class Bones::RPC::Parser::Buffer
Attributes
io[R]
Public Class Methods
new(data)
click to toggle source
# File lib/bones/rpc/parser/buffer.rb, line 9 def initialize(data) @io = data.is_a?(StringIO) ? data : StringIO.new(data) end
Public Instance Methods
getbyte()
click to toggle source
# File lib/bones/rpc/parser/buffer.rb, line 13 def getbyte io.getbyte end
getc()
click to toggle source
# File lib/bones/rpc/parser/buffer.rb, line 17 def getc io.getc end
pos()
click to toggle source
# File lib/bones/rpc/parser/buffer.rb, line 21 def pos io.pos end
read(n)
click to toggle source
# File lib/bones/rpc/parser/buffer.rb, line 25 def read(n) i = pos data = io.read(n) if data.nil? || data.bytesize < n seek(i) raise EOFError else data end end
rewind()
click to toggle source
# File lib/bones/rpc/parser/buffer.rb, line 36 def rewind io.rewind end
seek(pos)
click to toggle source
# File lib/bones/rpc/parser/buffer.rb, line 40 def seek(pos) io.seek(pos) end
size()
click to toggle source
# File lib/bones/rpc/parser/buffer.rb, line 44 def size io.size end
skip(n)
click to toggle source
# File lib/bones/rpc/parser/buffer.rb, line 48 def skip(n) seek(pos + n) end
sync(*others) { || ... }
click to toggle source
# File lib/bones/rpc/parser/buffer.rb, line 52 def sync(*others) yield ensure others.each { |other| other.seek(pos) } end
to_str()
click to toggle source
# File lib/bones/rpc/parser/buffer.rb, line 58 def to_str i = pos begin io.read || "" ensure seek(i) end end
transaction() { || ... }
click to toggle source
# File lib/bones/rpc/parser/buffer.rb, line 67 def transaction i = pos begin yield rescue EOFError => e seek(i) raise e end end
ungetc(c)
click to toggle source
# File lib/bones/rpc/parser/buffer.rb, line 77 def ungetc(c) io.ungetc(c) end