hw.go 691 Bytes
Newer Older
1 2 3 4 5
package hw

import (
	"encoding/json"

Ryan Goodfellow's avatar
Ryan Goodfellow committed
6
	"gitlab.com/mergetb/xir/lang/go/v0.2"
7 8 9
)

type Base struct {
10 11 12 13 14
	Manufacturer string   `json:"manufacturer,omitempty"`
	Model        string   `json:"model_name,omitempty"`
	SKU          string   `json:"model_name,omitempty"`
	Tags         []string `json:"tags,omitempty"`
	Integrated   bool     `json:"integrated,omitempty"`
15
	Cost         float64  `json:"cost,omitempty"`
16 17
}

Ryan Goodfellow's avatar
Ryan Goodfellow committed
18 19 20 21 22
type Element interface {
	BaseInfo() Base
	Show() string
}

23 24 25 26 27 28 29 30 31 32 33 34
func (b *Base) Tag(tags ...string) {
	b.Tags = append(b.Tags, tags...)
}

func toProps(thing interface{}) xir.Props {

	var result xir.Props
	buf, _ := json.Marshal(thing)
	json.Unmarshal(buf, &result)
	return result

}