Class: Zanders::Inventory
Constant Summary collapse
- INVENTORY_FILENAME =
"liveinv.xml"
Class Method Summary collapse
- .all(options = {}) ⇒ Object
- .get_quantity_file(options = {}) ⇒ Object
- .quantity(options = {}) ⇒ Object
Instance Method Summary collapse
- #all ⇒ Object
- #get_quantity_file ⇒ Object
-
#initialize(options = {}) ⇒ Inventory
constructor
A new instance of Inventory.
Methods inherited from Base
Constructor Details
#initialize(options = {}) ⇒ Inventory
Returns a new instance of Inventory.
6 7 8 9 |
# File 'lib/zanders/inventory.rb', line 6 def initialize( = {}) requires!(, :username, :password) @options = end |
Class Method Details
.all(options = {}) ⇒ Object
11 12 13 14 |
# File 'lib/zanders/inventory.rb', line 11 def self.all( = {}) requires!(, :username, :password) new().all end |
.get_quantity_file(options = {}) ⇒ Object
16 17 18 19 |
# File 'lib/zanders/inventory.rb', line 16 def self.get_quantity_file( = {}) requires!(, :username, :password) new().get_quantity_file end |
.quantity(options = {}) ⇒ Object
21 22 23 24 |
# File 'lib/zanders/inventory.rb', line 21 def self.quantity( = {}) requires!(, :username, :password) new().all end |
Instance Method Details
#all ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/zanders/inventory.rb', line 26 def all items = [] tempfile = get_file(INVENTORY_FILENAME) Nokogiri::XML(tempfile).xpath('//ZandersDataOut').each do |item| _map_hash = map_hash(item) items << _map_hash unless _map_hash.nil? end tempfile.close tempfile.unlink items end |
#get_quantity_file ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/zanders/inventory.rb', line 42 def get_quantity_file inventory_tempfile = get_file(INVENTORY_FILENAME) tempfile = Tempfile.new Nokogiri::XML(inventory_tempfile).xpath('//ZandersDataOut').each do |item| tempfile.puts("#{content_for(item, 'ITEMNO')},#{content_for(item, 'AVAILABLE')}") end inventory_tempfile.close inventory_tempfile.unlink tempfile.close tempfile.path end |