Documentation ¶
Index ¶
- func AppendString(b []byte, s string) []byte
- func AppendTime(b []byte, t time.Time) []byte
- func AppendValue(b []byte, v value.Value) []byte
- func AssertLength(s int, b []byte) error
- func BaseName(fileName string) (string, string)
- func FloatDefault(a *float64, b float64) float64
- func In(s string, p ...string) bool
- func Itoa(i int, p int) string
- func Match(s, pat string) bool
- func PadToLength(b []byte, l int) ([]byte, error)
- func ReadString(b []byte) (string, []byte)
- func ReadTime(b []byte) (time.Time, error)
- func ReadValue(b []byte) (value.Value, error)
- func Sprintf(f string, args ...interface{}) string
- func StringDefault(a, b string) string
- func ToFloat64(v interface{}) (float64, bool)
- func ToString(v interface{}) string
- func WindCompassDirection(d float64) string
- type DataSource
- func LimitedPseudoDataSource(c value.Calculator, period time2.Period, unit *value.Unit, ...) (DataSource, error)
- func PseudoDataSource(c value.Calculator, period time2.Period, unit *value.Unit, ...) (DataSource, error)
- func SliceDataSource(s []Entry, period time2.Period, unit *value.Unit) (DataSource, error)
- type Entry
- type StringMap
- type StringSet
- func (a *StringSet) Add(s string) bool
- func (a *StringSet) AddAll(s ...string)
- func (a *StringSet) Contains(s string) bool
- func (a *StringSet) Entries() []string
- func (a *StringSet) ForEach(f func(string) error) error
- func (a *StringSet) IsEmpty() bool
- func (a *StringSet) MarshalJSON() ([]byte, error)
- func (a *StringSet) Size() int
- func (a *StringSet) UnmarshalJSON(data []byte) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AppendString ¶
func AssertLength ¶
func BaseName ¶
BaseName splits the filename and file type from a path. if the file does not contain a '.' then this returns file,""
func FloatDefault ¶
func Match ¶
Match tests s against pattern pat.
If p starts and ends with '*' then this means contains the text between them.
If p starts with '*' only then means match the end of the pattern
If p ends with '*' only then means match the start of the pattern
A '|' allows for multiple patterns
A pattern of "" means always match
func ReadString ¶
func Sprintf ¶
Sprintf is similar to fmt.Sprintf except it is customised for handling our own data types.
It's primarily used by weatherbot with it's output formatting.
The format comprises the following:
%% % character
%d integer or floating point with 0 decimal places
%e The unit for Value's, "" otherwise
%f floating point
%.1f floating point 1 decimal place
%.2f floating point 2 decimal place
%.3f floating point 3 decimal place
%s String value
%t Trend, show ↓ → or ↑ depending on the trend value
%T Integer value in unix seconds - returns as "Jan 02 15:04:05 MST"
%u Unit value with unit suffix
%v interface value
%W Wind direction
func StringDefault ¶
func WindCompassDirection ¶
Types ¶
type DataSource ¶
type DataSource interface { // Size of the DataSource Size() int // Get a specific entry in the DataSource Get(int) (time.Time, value.Value) // Period returns the Period of the entries within the DataSource Period() time2.Period // GetYRange returns the Range of values in the DataSource GetYRange() *value.Range // GetUnit returns the Unit of the values in the DataSource GetUnit() *value.Unit // ForEach calls a function for each entry in the DataSource ForEach(func(int, time.Time, value.Value)) }
DataSource represents a collection of values to be plotted
func LimitedPseudoDataSource ¶
func LimitedPseudoDataSource(c value.Calculator, period time2.Period, unit *value.Unit, stepSize time.Duration, min, max value.Value, t value.Time) (DataSource, error)
LimitedPseudoDataSource is more optimal than PseudoDataSource as it doesn't have to precalculate the results as the min/max Value's are provided, so calculations are made on the fly.
func PseudoDataSource ¶
func PseudoDataSource(c value.Calculator, period time2.Period, unit *value.Unit, stepSize time.Duration, t value.Time) (DataSource, error)
PseudoDataSource returns a DataSource based on the output of a calculator
func SliceDataSource ¶
SliceDataSource returns a DataSource over a slice of Entry's
type StringMap ¶
func NewStringMap ¶
func NewStringMap() StringMap
type StringSet ¶
type StringSet map[string]interface{}
func NewStringSet ¶
func NewStringSet() StringSet