1
0
mirror of https://github.com/MontFerret/ferret.git synced 2024-12-16 11:37:36 +02:00
ferret/pkg/drivers/cdp/eval/param.go
Tim Voronov 82f7317ebe
Feature/#250 wait style (#257)
* Added WAIT_ATTR functions
2019-03-13 22:50:29 -04:00

37 lines
694 B
Go

package eval
import (
"github.com/MontFerret/ferret/pkg/runtime/core"
"github.com/MontFerret/ferret/pkg/runtime/values"
"strconv"
)
func Param(input core.Value) string {
switch value := input.(type) {
case values.String:
return ParamString(string(value))
case values.Float:
return ParamFloat(float64(value))
case values.Int:
return ParamInt(int64(value))
default:
if input == values.None {
return "null"
}
return value.String()
}
}
func ParamString(param string) string {
return `"` + param + `"`
}
func ParamFloat(param float64) string {
return strconv.FormatFloat(param, 'f', 6, 64)
}
func ParamInt(param int64) string {
return strconv.FormatInt(param, 64)
}