class BubbleWrap::Motion::Gyroscope

Public Instance Methods

active?() click to toggle source
# File motion/motion/gyroscope.rb, line 40
def active?
  @manager.gyroActive?
end
available?() click to toggle source
# File motion/motion/gyroscope.rb, line 36
def available?
  @manager.gyroAvailable?
end
data() click to toggle source
# File motion/motion/gyroscope.rb, line 44
def data
  @manager.gyroData
end
start(options={}, &handler) click to toggle source
# File motion/motion/gyroscope.rb, line 5
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
stop() click to toggle source
# File motion/motion/gyroscope.rb, line 48
def stop
  @manager.stopGyroUpdates
end

Private Instance Methods

handle_result(result_data, error, handler) click to toggle source
# File motion/motion/gyroscope.rb, line 20
        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