Module: InewsClient

Defined in:
lib/inews_client.rb,
lib/inews_client/queue.rb,
lib/inews_client/system.rb,
lib/inews_client/version.rb

Defined Under Namespace

Classes: Queue, System

Constant Summary collapse

VERSION =
"0.1.4.1"

Class Method Summary collapse

Class Method Details

.watch_queue(options, &block) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/inews_client.rb', line 7

def self.watch_queue(options, &block)
  fired_stories = []
  interval = options['interval'].to_i
  interval = 2 unless interval
  InewsClient::System.session(options) do |inews|
    inews.queue.with_queue(options) do |queue|
      loop do
        sleep(interval)
        queue.stories(options).select {|s| s.fired? }.each do |story|
          next if fired_stories.any? { |s| s.id == story.id }
          fired_stories << story
          block.call(story)
        end

      end
    end
  end
end