Class: MgeWholesale::Inventory
- Defined in:
- lib/mge_wholesale/inventory.rb
Constant Summary collapse
- INVENTORY_FILENAME =
'exportXML_cq_barcodeFFL.xml'
Class Method Summary collapse
- .all(options = {}, &block) ⇒ Object
- .get_quantity_file(options = {}) ⇒ Object
- .quantity(options = {}, &block) ⇒ Object
Instance Method Summary collapse
- #all(&block) ⇒ Object (also: #quantity)
- #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/mge_wholesale/inventory.rb', line 6 def initialize( = {}) requires!(, :username, :password) = end |
Class Method Details
.all(options = {}, &block) ⇒ Object
11 12 13 14 |
# File 'lib/mge_wholesale/inventory.rb', line 11 def self.all( = {}, &block) requires!(, :username, :password) new().all(&block) end |
.get_quantity_file(options = {}) ⇒ Object
16 17 18 19 |
# File 'lib/mge_wholesale/inventory.rb', line 16 def self.get_quantity_file( = {}) requires!(, :username, :password) new().get_quantity_file end |
.quantity(options = {}, &block) ⇒ Object
21 22 23 24 |
# File 'lib/mge_wholesale/inventory.rb', line 21 def self.quantity( = {}, &block) requires!(, :username, :password) new().all(&block) end |
Instance Method Details
#all(&block) ⇒ Object Also known as: quantity
26 27 28 29 30 31 32 33 34 35 |
# File 'lib/mge_wholesale/inventory.rb', line 26 def all(&block) tempfile = get_file(INVENTORY_FILENAME) Nokogiri::XML(tempfile).xpath('//item').each do |item| yield map_hash(item) end tempfile.close tempfile.unlink end |
#get_quantity_file ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/mge_wholesale/inventory.rb', line 37 def get_quantity_file inventory_tempfile = get_file(INVENTORY_FILENAME) tempfile = Tempfile.new Nokogiri::XML(inventory_tempfile).xpath('//item').each do |item| tempfile.puts("#{content_for(item, 'id')},#{content_for(item, 'qty')}") end inventory_tempfile.close inventory_tempfile.unlink tempfile.close tempfile.path end |