Sha256: 17f62f1ba170486189bac7e734571b618ac0a66a51ab265061fb0c6c1e0ec630

Contents?: true

Size: 1.19 KB

Versions: 8

Compression:

Stored size: 1.19 KB

Contents

module BubbleWrap
  module Motion
    class Accelerometer < GenericMotionInterface

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

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

        return self
      end

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

        handler.call(result, error)
      end

      def available?
        @manager.accelerometerAvailable?
      end

      def active?
        @manager.accelerometerActive?
      end

      def data
        @manager.accelerometerData
      end

      def stop
        @manager.stopAccelerometerUpdates
      end

    end

  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

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