Sha256: 829fd57566e0e55eff3094eb4801e0b1907c288c36db023a5fd636718a3cbcb8

Contents?: true

Size: 1.12 KB

Versions: 8

Compression:

Stored size: 1.12 KB

Contents

module BubbleWrap
  module Motion
    class Gyroscope < GenericMotionInterface

      def start(options={}, &handler)
        if options.key?(:interval)
          @manager.gyroUpdateInterval = options[:interval]
        end

        if handler
          queue = convert_queue(options[:queue])
          @manager.startGyroUpdatesToQueue(queue, withHandler: internal_handler(handler))
        else
          @manager.startGyroUpdates
        end

        return self
      end

      private def handle_result(result_data, error, handler)
        if result_data
          result = {
            data: result_data,
            rotation: result_data.rotationRate,
            x: result_data.rotationRate.x,
            y: result_data.rotationRate.y,
            z: result_data.rotationRate.z,
          }
        else
          result = nil
        end

        handler.call(result, error)
      end

      def available?
        @manager.gyroAvailable?
      end

      def active?
        @manager.gyroActive?
      end

      def data
        @manager.gyroData
      end

      def stop
        @manager.stopGyroUpdates
      end

    end

  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
bubble-wrap-1.9.7 motion/motion/gyroscope.rb
bubble-wrap-1.9.6 motion/motion/gyroscope.rb
bubble-wrap-1.9.5 motion/motion/gyroscope.rb
bubble-wrap-1.9.4 motion/motion/gyroscope.rb
bubble-wrap-1.9.3 motion/motion/gyroscope.rb
bubble-wrap-1.9.2 motion/motion/gyroscope.rb
bubble-wrap-1.9.1 motion/motion/gyroscope.rb
bubble-wrap-1.9.0 motion/motion/gyroscope.rb