class OrionWholesale::Inventory
Public Class Methods
all(options = {})
click to toggle source
# File lib/orion_wholesale/inventory.rb, line 9 def self.all(options = {}) requires!(options, :username, :password) new(options).all end
new(options = {})
click to toggle source
# File lib/orion_wholesale/inventory.rb, line 4 def initialize(options = {}) requires!(options, :username, :password) @options = options end
quantity(options = {})
click to toggle source
# File lib/orion_wholesale/inventory.rb, line 14 def self.quantity(options = {}) requires!(options, :username, :password) new(options).quantity end
Public Instance Methods
all()
click to toggle source
# File lib/orion_wholesale/inventory.rb, line 19 def all tempfile = get_most_recent_file(OrionWholesale.config.catalog_filename_prefix, OrionWholesale.config.top_level_dir) items = [] File.open(tempfile).each_with_index do |row, i| row = row.split("\t") if i==0 @headers = row next end item = { item_identifier: row[@headers.index('Item ID')].strip, quantity: row[@headers.index('Qty available')].to_i, price: row[@headers.index('Price')].strip, } items << item end tempfile.close tempfile.unlink items end
quantity()
click to toggle source
# File lib/orion_wholesale/inventory.rb, line 46 def quantity tempfile = get_most_recent_file(OrionWholesale.config.catalog_filename_prefix, OrionWholesale.config.top_level_dir) items = [] File.open(tempfile).each_with_index do |row, i| row = row.split("\t") if i==0 @headers = row next end item = { item_identifier: row[@headers.index('Item ID')].strip, quantity: row[@headers.index('Qty available')].to_i, } items << item end tempfile.close tempfile.unlink items end