Class: GunAccessorySupply::Tracking

Inherits:
Base
  • Object
show all
Defined in:
lib/gun_accessory_supply/tracking.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

connect

Constructor Details

#initialize(options = {}) ⇒ Tracking



4
5
6
7
8
# File 'lib/gun_accessory_supply/tracking.rb', line 4

def initialize(options = {})
  requires!(options, :username, :password)

  @options = options
end

Class Method Details

.file_data(options = {}, filename) ⇒ Object



16
17
18
19
20
# File 'lib/gun_accessory_supply/tracking.rb', line 16

def self.file_data(options = {}, filename)
  requires!(options, :username, :password)

  new(options).file_data(filename)
end

.file_names(options = {}, po_numbers = []) ⇒ Object



10
11
12
13
14
# File 'lib/gun_accessory_supply/tracking.rb', line 10

def self.file_names(options = {}, po_numbers = [])
  requires!(options, :username, :password)

  new(options).file_names(po_numbers)
end

Instance Method Details

#file_data(filename) ⇒ Object



34
35
36
# File 'lib/gun_accessory_supply/tracking.rb', line 34

def file_data(filename)
  CXML::Parser.new.parse(get_file(filename, 'out').read)
end

#file_names(po_numbers = []) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
# File 'lib/gun_accessory_supply/tracking.rb', line 22

def file_names(po_numbers = [])
  filename_regexes = if po_numbers.empty?
    [/#{GunAccessorySupply.config.tracking_filename_prefix}.*.xml/]
  else
    po_numbers.map do |po_number|
      /#{GunAccessorySupply.config.tracking_filename_prefix}.*#{po_number}.xml/
    end
  end

  get_full_filenames(filename_regexes, 'out')
end