Class: Nodectl::Stream::FileWithMemory

Inherits:
File
  • Object
show all
Defined in:
lib/nodectl/stream/file_with_memory.rb

Instance Method Summary collapse

Methods inherited from File

#close, #closed?, #onclose, #read_chunk

Constructor Details

#initialize(file, options = {}) ⇒ FileWithMemory

Returns a new instance of FileWithMemory.



2
3
4
5
6
# File 'lib/nodectl/stream/file_with_memory.rb', line 2

def initialize(file, options = {})
  super(file, options)

  @memory = ""
end

Instance Method Details

#onread(&blk) ⇒ Object



8
9
10
11
# File 'lib/nodectl/stream/file_with_memory.rb', line 8

def onread(&blk)
  blk.call(@memory)
  @onread << blk
end

#onread_call(chunk) ⇒ Object



13
14
15
16
# File 'lib/nodectl/stream/file_with_memory.rb', line 13

def onread_call(chunk)
  @memory << chunk
  super(chunk)
end