Class: Hiredis::Ruby::Reader

Inherits:
Object
  • Object
show all
Defined in:
lib/hiredis/ruby/reader.rb

Defined Under Namespace

Classes: Buffer, Task

Instance Method Summary collapse

Constructor Details

#initializeReader

Returns a new instance of Reader.



7
8
9
10
# File 'lib/hiredis/ruby/reader.rb', line 7

def initialize
  @buffer = Buffer.new
  @task = Task.new(@buffer)
end

Instance Method Details

#feed(data) ⇒ Object



12
13
14
# File 'lib/hiredis/ruby/reader.rb', line 12

def feed(data)
  @buffer << data
end

#getsObject



16
17
18
19
20
# File 'lib/hiredis/ruby/reader.rb', line 16

def gets
  reply = @task.process
  @buffer.discard!
  reply
end