Class: ADSP::Stream::Raw::Abstract

Inherits:
Object
  • Object
show all
Defined in:
lib/adsp/stream/raw/abstract.rb

Overview

ADSP::Stream::Raw::Abstract class.

Direct Known Subclasses

Compressor, Decompressor

Instance Method Summary collapse

Constructor Details

#initialize(native_stream) ⇒ Abstract

Initializes raw stream using native_stream.



13
14
15
16
# File 'lib/adsp/stream/raw/abstract.rb', line 13

def initialize(native_stream)
  @native_stream = native_stream
  @is_closed     = false
end

Instance Method Details

#close(&writer) ⇒ Object

Writes next result using writer proc and closes raw stream.



53
54
55
56
57
58
59
60
# File 'lib/adsp/stream/raw/abstract.rb', line 53

def close(&writer)
  write_result(&writer)

  @native_stream.close
  @is_closed = true

  nil
end

#closed?Boolean

Returns whether raw stream is closed.

Returns:

  • (Boolean)


63
64
65
# File 'lib/adsp/stream/raw/abstract.rb', line 63

def closed?
  @is_closed
end

#flush(&writer) ⇒ Object

Flushes raw stream and writes next result using writer proc.



21
22
23
24
25
26
27
28
29
# File 'lib/adsp/stream/raw/abstract.rb', line 21

def flush(&writer)
  do_not_use_after_close

  Validation.validate_proc writer

  write_result(&writer)

  nil
end