Documentation
¶
Index ¶
- type Price
- type Station
- func (s *Station) AddPrice(timestamp int64, fuel string, price float64)
- func (s *Station) IsBestStation(timestamp int64, fuel string, goodPrice float64) bool
- func (s *Station) LatestPrice(fuel string) (timestamp int64, price float64, err error)
- func (s *Station) PricesSince(since int64, fuel string) []float64
- func (s *Station) Update(brand, name, place string)
- type StationMap
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Station ¶
type Station struct {
Brand string // The brand of the station
Name string // The name of the station
Place string // The place of the station (city name)
Latest map[string]*Price // Latest price for the given fuel
Prices map[string]map[int64]float64 // The price history for the fuel type
}
Station represents a gas station with its price history
func NewStation ¶
NewStation returns a new Station
func (*Station) AddPrice ¶
AddPrice adds a fuel price to a station for the given unix epoch timestamp
func (*Station) IsBestStation ¶
IsBestStation returns true if the price for the given fuel and timestamp is below the given good price
func (*Station) LatestPrice ¶
LatestPrice returns the latest price for the given fuel type
func (*Station) PricesSince ¶
PricesSince returns a slice of float64 with the prices since the given epoch timestamp and for the given fuel type
type StationMap ¶
StationMap is a map of stations with the station ID as the key
func NewStationMap ¶
func NewStationMap() StationMap
NewStationMap returns an initialized StationMap
Click to show internal directories.
Click to hide internal directories.