Documentation ¶
Index ¶
- Constants
- Variables
- type Clock
- type ClockVal
- func (c *ClockVal) CreateSpeedMeter(start, stop, current float64) string
- func (c *ClockVal) Format(d time.Duration) string
- func (c *ClockVal) IsStartTimeSet() error
- func (c *ClockVal) Now()
- func (c *ClockVal) Remaining(fraction float64) time.Duration
- func (c *ClockVal) Seconds(d time.Duration) float64
- func (c *ClockVal) SetStartTime()
- func (c *ClockVal) Start() time.Time
- func (c *ClockVal) Subtract() time.Duration
- type Set
- func (s *Set) CreateBarString(numStepsCompleted int) string
- func (s *Set) GetCurrentIterationSymbol() string
- func (s *Set) GetDescription() string
- func (s *Set) GetFinishedIterationSymbol() string
- func (s *Set) GetLParen() string
- func (s *Set) GetLineSize() int
- func (s *Set) GetMaxLineSize() int
- func (s *Set) GetRParen() string
- func (s *Set) GetRemainingIterationSymbol() string
- func (s *Set) GetSuffix() string
- func (s *Set) SetCurrentIterationSymbol(str string)
- func (s *Set) SetDescription(str string)
- func (s *Set) SetFinishedIterationSymbol(str string)
- func (s *Set) SetIdealLineSize() error
- func (s *Set) SetLParen(str string)
- func (s *Set) SetLineSize(i int)
- func (s *Set) SetMaxLineSize(i int)
- func (s *Set) SetRParen(str string)
- func (s *Set) SetRemainingIterationSymbol(str string)
- func (s *Set) SetSuffix(value string)
- type Settings
- type Vals
- func (v *Vals) GetCurrent() float64
- func (v *Vals) GetIsObject() bool
- func (v *Vals) GetStart() float64
- func (v *Vals) GetStep() float64
- func (v *Vals) GetStop() float64
- func (v *Vals) SetCurrent(s float64)
- func (v *Vals) SetIsObject(value bool)
- func (v *Vals) SetStart(s float64)
- func (v *Vals) SetStep(s float64)
- func (v *Vals) SetStop(s float64)
- func (v *Vals) Statistics(linesize int) (string, int)
- type Values
- type Write
- type Writing
Constants ¶
const ( NumberOfCharacters = 66 NumberOfCharactersBuffer = 12 )
NumberOfCharacters is the number of characters that the pbar display takes up NumberOfCharactersBuffer is the number of characters to leave out (for large numbers)
Variables ¶
var ( DefaultDescription = "" DefaultFinishedIterationSymbol = "\u2588" DefaultCurrentIterationSymbol = "\u2588" DefaultRemainingIterationSymbol = " " DefaultLParen = "|" DefaultRParen = "|" DefaultMaxLineSize = 80 DefaultLineSize = 10 DefaultSuffix = "\n" )
The default values for all the parameter settings
var ( TerminalSize = terminal.GetSize GetTerminal = os.Stdin.Fd )
Terminal and os functions used to examine terminal size
var DefaultWriter = os.Stdout
DefaultWriter is the standard place to write to
var NowTime = time.Now
NowTime allows us to stub out time.Now() easily
Functions ¶
This section is empty.
Types ¶
type Clock ¶
type Clock interface { Now() Subtract() time.Duration SetStartTime() Start() time.Time Seconds(time.Duration) float64 Remaining(float64) time.Duration Format(time.Duration) string IsStartTimeSet() error CreateSpeedMeter(float64, float64, float64) string }
Clock enables various operations relating to time to be performed easily.
type ClockVal ¶
ClockVal implements a real-time clock by wrapping functions from the time module. It also contains a start time relating to when the Pbar object was initialized.
func (*ClockVal) CreateSpeedMeter ¶
CreateSpeedMeter forms the part of the progress bar relating to the elapsed and remaining time, as well as the rate of iterations per second.
func (*ClockVal) Format ¶
Format enables a time.Duration object to be formatted into a string format that can be easily integrated into the progress bar.
func (*ClockVal) IsStartTimeSet ¶
IsStartTimeSet checks if the start time is set and returns an error if not
func (*ClockVal) Now ¶
func (c *ClockVal) Now()
Now returns the current time (from the time module).
func (*ClockVal) Remaining ¶
Remaining returns a time.Duration object equating to the fraction of progress that has been performed.
func (*ClockVal) SetStartTime ¶
func (c *ClockVal) SetStartTime()
SetStartTime enables the StartTime value to be set in the clock object.
type Set ¶
type Set struct { Description string FinishedIterationSymbol string CurrentIterationSymbol string RemainingIterationSymbol string LineSize int MaxLineSize int LParen string RParen string Suffix string }
Set holds the setting parameters
func (*Set) CreateBarString ¶
CreateBarString creates the actual 'bar' within the progress bar
func (*Set) GetCurrentIterationSymbol ¶
GetCurrentIterationSymbol gets the CurrentIterationSymbol value
func (*Set) GetDescription ¶
GetDescription gets the Description value
func (*Set) GetFinishedIterationSymbol ¶
GetFinishedIterationSymbol gets the FinishedIterationSymbol value
func (*Set) GetMaxLineSize ¶
GetMaxLineSize gets the MaxLineSize value
func (*Set) GetRemainingIterationSymbol ¶
GetRemainingIterationSymbol gets the RemainingIterationSymbol value
func (*Set) SetCurrentIterationSymbol ¶
SetCurrentIterationSymbol sets the CurrentIterationSymbol value
func (*Set) SetDescription ¶
SetDescription sets the Description value
func (*Set) SetFinishedIterationSymbol ¶
SetFinishedIterationSymbol sets the FinishedIterationSymbol value
func (*Set) SetIdealLineSize ¶
SetIdealLineSize sets the line size to be almost the same size as the current terminal
func (*Set) SetMaxLineSize ¶
SetMaxLineSize sets the MaxLineSize value
func (*Set) SetRemainingIterationSymbol ¶
SetRemainingIterationSymbol sets the RemainingIterationSymbol value
type Settings ¶
type Settings interface { SetDescription(string) SetFinishedIterationSymbol(string) SetCurrentIterationSymbol(string) SetRemainingIterationSymbol(string) SetLineSize(int) SetMaxLineSize(int) SetLParen(string) SetRParen(string) SetSuffix(string) SetIdealLineSize() error GetDescription() string GetFinishedIterationSymbol() string GetCurrentIterationSymbol() string GetRemainingIterationSymbol() string GetLineSize() int GetMaxLineSize() int GetLParen() string GetRParen() string GetSuffix() string CreateBarString(int) string }
Settings enables the setting and getting the setting parameters for the progress bar. It also enables the creation of the bar string
type Vals ¶
Vals holds the Start, Stop, Step and Current values
func (*Vals) SetIsObject ¶
SetIsObject sets the IsObject value
type Values ¶
type Values interface { SetStart(float64) SetStop(float64) SetStep(float64) SetCurrent(float64) SetIsObject(bool) GetStart() float64 GetStop() float64 GetStep() float64 GetCurrent() float64 GetIsObject() bool Statistics(int) (string, int) }
Values holds the start, stop, step and current values for the progress bar. It also enables statistics to be calculated for these values relating to the ratio of completion.