Class: AVCapture::ImagePromise

Inherits:
Object
  • Object
show all
Defined in:
lib/av_capture.rb

Instance Method Summary collapse

Constructor Details

#initialize(io) ⇒ ImagePromise

Returns a new instance of ImagePromise.



18
19
20
21
22
# File 'lib/av_capture.rb', line 18

def initialize io
  @io    = io
  @data  = nil
  @mutex = Mutex.new
end

Instance Method Details

#dataObject Also known as: read



26
27
28
29
30
# File 'lib/av_capture.rb', line 26

def data
  @data || @mutex.synchronize do
    @data ||= @io.read.tap { @io.close }
  end
end

#to_ioObject



24
# File 'lib/av_capture.rb', line 24

def to_io; @io; end