Class: Zanders::Inventory
Constant Summary collapse
- INVENTORY_FILENAME =
"liveinv.xml"
Class Method Summary collapse
- .all(chunk_size = 100, options = {}, &block) ⇒ Object
- .get_file(options = {}) ⇒ Object
- .get_quantity_file(options = {}) ⇒ Object
- .quantity(chunk_size = 100, options = {}, &block) ⇒ Object
Instance Method Summary collapse
- #all(chunk_size, &block) ⇒ 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 10 |
# File 'lib/zanders/inventory.rb', line 6 def initialize( = {}) requires!(, :username, :password) = end |
Class Method Details
.all(chunk_size = 100, options = {}, &block) ⇒ Object
12 13 14 15 |
# File 'lib/zanders/inventory.rb', line 12 def self.all(chunk_size = 100, = {}, &block) requires!(, :username, :password) new().all(chunk_size, &block) end |
.get_file(options = {}) ⇒ Object
27 28 29 30 |
# File 'lib/zanders/inventory.rb', line 27 def self.get_file( = {}) requires!(, :username, :password) new().get_file end |
.get_quantity_file(options = {}) ⇒ Object
17 18 19 20 |
# File 'lib/zanders/inventory.rb', line 17 def self.get_quantity_file( = {}) requires!(, :username, :password) new().get_quantity_file end |
.quantity(chunk_size = 100, options = {}, &block) ⇒ Object
22 23 24 25 |
# File 'lib/zanders/inventory.rb', line 22 def self.quantity(chunk_size = 100, = {}, &block) requires!(, :username, :password) new().all(chunk_size, &block) end |
Instance Method Details
#all(chunk_size, &block) ⇒ Object
32 33 34 35 36 37 38 39 40 41 |
# File 'lib/zanders/inventory.rb', line 32 def all(chunk_size, &block) tempfile = get_file(INVENTORY_FILENAME) xml_doc = Nokogiri::XML(tempfile.open) xml_doc.xpath('//ZandersDataOut').each do |item| map_hash(item) end tempfile.unlink end |
#get_quantity_file ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/zanders/inventory.rb', line 43 def get_quantity_file inventory_tempfile = get_file(INVENTORY_FILENAME) tempfile = Tempfile.new xml_doc = Nokogiri::XML(inventory_tempfile.open) xml_doc.xpath('//ZandersDataOut').each do |item| tempfile.puts("#{content_for(item, 'ITEMNO')},#{content_for(item, 'AVAILABLE')}") end inventory_tempfile.unlink tempfile.close tempfile.path end |