1
0

Add id to each shipment

This commit is contained in:
Tim Kächele 2023-09-03 08:31:11 +02:00
parent b7eddf7ab1
commit c8396afca5

View File

@ -3,6 +3,7 @@ module PlanetExpressExpress
class ShipmentReader class ShipmentReader
def initialize(prices) def initialize(prices)
@prices = prices @prices = prices
@id = 0
end end
# Expects to read a file # Expects to read a file
@ -46,7 +47,8 @@ module PlanetExpressExpress
parts = line.split(" ") parts = line.split(" ")
shipment = { shipment = {
date: Date.parse(parts[0]), id: sequential_id,
date: Date.strptime(parts[0], "%Y-%m-%d"),
size: parts[1]&.to_sym, size: parts[1]&.to_sym,
provider: parts[2]&.to_sym, provider: parts[2]&.to_sym,
price: 0, price: 0,
@ -62,5 +64,9 @@ module PlanetExpressExpress
shipment shipment
end end
def sequential_id
@id += 1
end
end end
end end