You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

45 lines
590 B

4 years ago
package value
import (
"strconv"
"gitoa.ru/go-4devs/console/input/value/flag"
4 years ago
)
type Float64 struct {
empty
4 years ago
Val []float64
4 years ago
Flag flag.Flag
4 years ago
}
func (f *Float64) Append(in string) error {
v, err := strconv.ParseFloat(in, 64)
if err != nil {
return err
}
f.Val = append(f.Val, v)
return nil
}
func (f *Float64) Float64() float64 {
if !f.Flag.IsArray() && len(f.Val) == 1 {
return f.Val[0]
}
return 0
}
func (f *Float64) Float64s() []float64 {
return f.Val
}
func (f *Float64) Any() interface{} {
4 years ago
if f.Flag.IsArray() {
4 years ago
return f.Float64s()
}
return f.Float64()
}