Class: SabnzbdPlusApi::UnannouncedAdded

Inherits:
Object
  • Object
show all
Defined in:
lib/sabnzbd_plus/api/unannounced_added.rb

Overview

Get all of the slots which are active or in history and that have not yet been announced

Instance Method Summary (collapse)

Constructor Details

- (UnannouncedAdded) initialize(mapper = SabnzbdPlusModel::Mapper.new)

Load the mapper, empty the list of announced nzo ids

Parameters:

  • mapper (SabnzbdPlusModel::Mapper) (defaults to: SabnzbdPlusModel::Mapper.new)

    defaults to new SabnzbdPlusModel::Mapper



10
11
12
13
# File 'lib/sabnzbd_plus/api/unannounced_added.rb', line 10

def initialize(mapper = SabnzbdPlusModel::Mapper.new)
  @mapper = mapper
  @announced_nzos = []
end

Instance Method Details

- (Array<Slot>) process

Get all of the unannounced history and queue slots



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/sabnzbd_plus/api/unannounced_added.rb', line 20

def process
  queue = @mapper.current_queue
  return_array = []

  queue.slots.each { |slot|
    unless @announced_nzos.include? slot.nzo_id
      return_array = return_array << slot
      @announced_nzos = @announced_nzos << slot.nzo_id
    end
  }

  history = @mapper.history
  
  history.slots.each { |slot|
    unless @announced_nzos.include? slot.nzo_id
      return_array = return_array << slot
      @announced_nzos = @announced_nzos << slot.nzo_id
    end
  }

  return return_array
end