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.



25
26
27
28
29
# File 'lib/thrift/protocol/json_protocol.rb', line 25

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

Instance Method Details

#peekObject



41
42
43
44
45
46
47
# File 'lib/thrift/protocol/json_protocol.rb', line 41

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

#readObject



31
32
33
34
35
36
37
38
39
# File 'lib/thrift/protocol/json_protocol.rb', line 31

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

  return @data
end