station

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 6, 2020 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Price

type Price struct {
	Timestamp int64
	Value     float64
}

Price represents a price for a specific timestamp

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

func NewStation(brand, name, place string) *Station

NewStation returns a new Station

func (*Station) AddPrice

func (s *Station) AddPrice(timestamp int64, fuel string, price float64)

AddPrice adds a fuel price to a station for the given unix epoch timestamp

func (*Station) IsBestStation

func (s *Station) IsBestStation(timestamp int64, fuel string, goodPrice float64) bool

IsBestStation returns true if the price for the given fuel and timestamp is below the given good price

func (*Station) LatestPrice

func (s *Station) LatestPrice(fuel string) (timestamp int64, price float64, err error)

LatestPrice returns the latest price for the given fuel type

func (*Station) PricesSince

func (s *Station) PricesSince(since int64, fuel string) []float64

PricesSince returns a slice of float64 with the prices since the given epoch timestamp and for the given fuel type

func (*Station) Update

func (s *Station) Update(brand, name, place string)

Update updates the data of a station

type StationMap

type StationMap map[string]*Station

StationMap is a map of stations with the station ID as the key

func NewStationMap

func NewStationMap() StationMap

NewStationMap returns an initialized StationMap

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL