Documentation ¶
Index ¶
- func AutoFlush(tr *ansiterm.TabWriter)
- func DetermineCaptainFlag(pick responses.Pick) string
- func GetPlayerName(pick responses.Pick, bootstrap responses.BootstrapData) string
- func GetPoints(pick responses.Pick, live responses.GameweekLiveScores) int
- type ConfigReader
- type FplGameweekParser
- type FplTeamsParser
- func (t FplTeamsParser) CalculateMonetaryValue(value int) float32
- func (t FplTeamsParser) CalculateRankComparison(league responses.ClassicLeague) string
- func (t FplTeamsParser) GetTeam(teamID int, bootstrap responses.BootstrapData) string
- func (t FplTeamsParser) GetTeamID(teamID string, config ConfigReader) (int, error)
- type GameweekParser
- type TeamsParser
- type ViperConfigReader
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AutoFlush ¶
AutoFlush handles the management of any errors that may be outputted after flushing the tab writer
func DetermineCaptainFlag ¶
DetermineCaptainFlag will work out whether or not the pick provided is the captain or vice, and if so return the appropriate string: (C) or (VC)
func GetPlayerName ¶
func GetPlayerName(pick responses.Pick, bootstrap responses.BootstrapData) string
GetPlayerName will cross reference the pick with the bootstrap data to determine the players web appropriate name
Types ¶
type ConfigReader ¶
type ConfigReader interface { GetString(key string) string GetStringSlice(key string) []string GetInt(key string) int IsSet(key string) bool }
ConfigReader interface helps me to abstract away config retrieval to better unit test the tool
type FplGameweekParser ¶
type FplGameweekParser struct { }
FplGameweekParser handles any gameweek related parsing that needs to be done
func (FplGameweekParser) GetCurrentGameweek ¶
func (g FplGameweekParser) GetCurrentGameweek(gameweeks []responses.Gameweek, config ConfigReader) (int, error)
GetCurrentGameweek uses the bootstrap data to determine which gameweek is currently active in the game. If all are finished, defaults to 38
type FplTeamsParser ¶
type FplTeamsParser struct { }
FplTeamsParser handles any team related parsing that needs to be done
func (FplTeamsParser) CalculateMonetaryValue ¶
func (t FplTeamsParser) CalculateMonetaryValue(value int) float32
CalculateMonetaryValue returns a correctly decimalised team value
func (FplTeamsParser) CalculateRankComparison ¶
func (t FplTeamsParser) CalculateRankComparison(league responses.ClassicLeague) string
CalculateRankComparison returns the correct icon depending on rank change
func (FplTeamsParser) GetTeam ¶
func (t FplTeamsParser) GetTeam(teamID int, bootstrap responses.BootstrapData) string
GetTeam cross references the teamId with the bootstrap data to get the official team name
func (FplTeamsParser) GetTeamID ¶
func (t FplTeamsParser) GetTeamID(teamID string, config ConfigReader) (int, error)
GetTeamID will either convert the teamID provided to an int, or return the teamID stored in config under "team-id"
type GameweekParser ¶
type GameweekParser interface {
GetCurrentGameweek(gameweeks []responses.Gameweek, config ConfigReader) (int, error)
}
GameweekParser helps me abstract away the gaameweek related work so I can better unit test it
type TeamsParser ¶
type TeamsParser interface { GetTeamID(teamID string, config ConfigReader) (int, error) GetTeam(teamID int, bootstrap responses.BootstrapData) string CalculateMonetaryValue(value int) float32 CalculateRankComparison(league responses.ClassicLeague) string }
TeamsParser helps me abstract away the team related work so I can better unit test it
type ViperConfigReader ¶
type ViperConfigReader struct { }
ViperConfigReader is a concrete implementation of the ConfigReader interface
func (ViperConfigReader) GetInt ¶
func (v ViperConfigReader) GetInt(key string) int
GetInt returns an int type config entry
func (ViperConfigReader) GetString ¶
func (v ViperConfigReader) GetString(key string) string
GetString returns a string type config entry
func (ViperConfigReader) GetStringSlice ¶
func (v ViperConfigReader) GetStringSlice(key string) []string
GetStringSlice returns a string slice type config entry
func (ViperConfigReader) IsSet ¶
func (v ViperConfigReader) IsSet(key string) bool
IsSet confirms the existence of a config key