class BubbleWrap::Motion::GenericMotionInterface

Public Class Methods

new(manager) click to toggle source
# File motion/motion/motion.rb, line 61
def initialize(manager)
  @manager = manager
end

Public Instance Methods

every(time=nil, options={}, &blk) click to toggle source
# File motion/motion/motion.rb, line 73
def every(time=nil, options={}, &blk)
  raise "A block is required" unless blk
  blk.weak! if BubbleWrap.use_weak_callbacks?

  if time.is_a?(NSDictionary)
    options = time
  elsif time
    options = options.merge(interval: time)
  end

  self.start(options, &blk)
  return self
end
once(options={}, &blk) click to toggle source
# File motion/motion/motion.rb, line 87
def once(options={}, &blk)
  raise "A block is required" unless blk
  blk.weak! if BubbleWrap.use_weak_callbacks?

  @called_once = false
  every(options) do |result, error|
    unless @called_once
      @called_once = true
      blk.call(result, error)
    end
    self.stop
  end

  return self
end
repeat(options={}, &blk) click to toggle source
# File motion/motion/motion.rb, line 65
def repeat(options={}, &blk)
  raise "A block is required" unless blk
  blk.weak! if BubbleWrap.use_weak_callbacks?

  self.start(options, &blk)
  return self
end

Private Instance Methods

convert_queue(queue_name) click to toggle source
# File motion/motion/motion.rb, line 103
        def convert_queue(queue_name)
  case queue_name
  when :main, nil
    return NSOperationQueue.mainQueue
  when :background
    queue = NSOperationQueue.new
    queue.name = 'com.bubble-wrap.core-motion.background-queue'
    return queue
  when :current
    return NSOperationQueue.currentQueue
  when String
    queue = NSOperationQueue.new
    queue.name = queue_name
    return queue
  else
    queue_name
  end
end
internal_handler(handler) click to toggle source
# File motion/motion/motion.rb, line 122
        def internal_handler(handler)
  retval = -> (result_data, error) do
    handle_result(result_data, error, handler)
  end
  retval.weak! if BubbleWrap.use_weak_callbacks?
  retval
end