MCPcopy Create free account
hub / github.com/devfile/api / Numbers

Method Numbers

pkg/attributes/attributes.go:250–261  ·  view source on GitHub ↗

Numbers allows returning only the attributes whose content is a JSON number. An optional error holder can be passed as an argument to receive any error that might have be raised during the attribute decoding

(errorHolder *error)

Source from the content-addressed store, hash-verified

248// to receive any error that might have be raised during the attribute
249// decoding
250func (attributes Attributes) Numbers(errorHolder *error) map[string]float64 {
251 result := map[string]float64{}
252 for key := range attributes {
253 // Here only the last error is returned.
254 // Let's keep it simple and avoid adding a dependency
255 // on an external package just for gathering errors.
256 if value, isRightType := attributes.Get(key, errorHolder).(float64); isRightType {
257 result[key] = value
258 }
259 }
260 return result
261}
262
263// Booleans allows returning only the attributes whose content
264// is a JSON boolean.

Callers 1

TestDecodeAttributesFunction · 0.80

Calls 1

GetMethod · 0.95

Tested by 1

TestDecodeAttributesFunction · 0.64