Sha256: 75f9878294ef82c8804b7d22923a53c06261370be9e5c1340c73c17db8d4f8c9
Contents?: true
Size: 1.38 KB
Versions: 4
Compression:
Stored size: 1.38 KB
Contents
module Zanders class Inventory < Base INVENTORY_FILENAME = "zandersinv.csv" QUANTITY_FILENAME = "liveinv.csv" def initialize(options = {}) requires!(options, :username, :password) @options = options end def self.all(chunk_size = 15, options = {}, &block) requires!(options, :username, :password) new(options).all(chunk_size, &block) end def self.quantities(chunk_size = 15, options = {}, &block) requires!(options, :username, :password) new(options).quantities(chunk_size, &block) end def all(chunk_size, &block) connect(@options) do |ftp| csv_tempfile = Tempfile.new ftp.chdir(Zanders.config.ftp_directory) ftp.getbinaryfile(INVENTORY_FILENAME, csv_tempfile.path) SmarterCSV.process(csv_tempfile, { :chunk_size => chunk_size, :convert_values_to_numeric => false }) do |chunk| yield(chunk) end csv_tempfile.unlink end end def quantities(chunk_size, &block) connect(@options) do |ftp| csv_tempfile = Tempfile.new ftp.chdir(Zanders.config.ftp_directory) ftp.getbinaryfile(QUANTITY_FILENAME, csv_tempfile.path) SmarterCSV.process(csv_tempfile, { :chunk_size => chunk_size, :convert_values_to_numeric => false }) do |chunk| yield(chunk) end csv_tempfile.unlink end end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
zanders-1.2 | lib/zanders/inventory.rb |
zanders-1.1.5 | lib/zanders/inventory.rb |
zanders-1.1.4 | lib/zanders/inventory.rb |
zanders-1.1.3 | lib/zanders/inventory.rb |