Class: Thrift::LookaheadReader

Inherits:
Object
  • Object
show all
Defined in:
lib/thrift/protocol/json_protocol.rb

Instance Method Summary collapse

Constructor Details

#initialize(trans) ⇒ LookaheadReader

Returns a new instance of LookaheadReader.



39
40
41
42
43
# File 'lib/thrift/protocol/json_protocol.rb', line 39

def initialize(trans)
  @trans = trans
  @hasData = false
  @data = nil
end

Instance Method Details

#peekObject



55
56
57
58
59
60
61
# File 'lib/thrift/protocol/json_protocol.rb', line 55

def peek
  if !@hasData
    @data = @trans.read(1)
  end
  @hasData = true
  return @data
end

#readObject



45
46
47
48
49
50
51
52
53
# File 'lib/thrift/protocol/json_protocol.rb', line 45

def read
  if @hasData
    @hasData = false
  else
    @data = @trans.read(1)
  end

  return @data
end