Add id to each shipment
This commit is contained in:
parent
b7eddf7ab1
commit
c8396afca5
@ -3,6 +3,7 @@ module PlanetExpressExpress
|
||||
class ShipmentReader
|
||||
def initialize(prices)
|
||||
@prices = prices
|
||||
@id = 0
|
||||
end
|
||||
|
||||
# Expects to read a file
|
||||
@ -46,7 +47,8 @@ module PlanetExpressExpress
|
||||
parts = line.split(" ")
|
||||
|
||||
shipment = {
|
||||
date: Date.parse(parts[0]),
|
||||
id: sequential_id,
|
||||
date: Date.strptime(parts[0], "%Y-%m-%d"),
|
||||
size: parts[1]&.to_sym,
|
||||
provider: parts[2]&.to_sym,
|
||||
price: 0,
|
||||
@ -62,5 +64,9 @@ module PlanetExpressExpress
|
||||
|
||||
shipment
|
||||
end
|
||||
|
||||
def sequential_id
|
||||
@id += 1
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user