Sha256: 276831828c92735506eb607ef7e150cc34d3b2458434ccbd0e21c0dc6b71e5f8

Contents?: true

Size: 475 Bytes

Versions: 2

Compression:

Stored size: 475 Bytes

Contents

require 'thread'

module QRTools
  module UI
    class Camera
      @@locks = Hash.new { |h,k| h[k] = Mutex.new }

      def initialize camera_number
        @camera_number = camera_number
        if block_given?
          start
          yield self
          stop
        end
      end

      def start
        @@locks[@camera_number].lock
        native_start
      end

      def stop
        @@locks[@camera_number].unlock
        native_stop
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
qrtools-1.0.1 lib/qrtools/ui/camera.rb
qrtools-1.0.0 lib/qrtools/ui/camera.rb