Added test for minimal example. Omit optional values when not set. Added messages for route info, production drop and route end.

This commit is contained in:
Oliver Jakoubek 2020-05-29 11:02:33 +02:00
commit df964e0ecf
9 changed files with 283 additions and 8 deletions

46
production_drop.go Normal file
View file

@ -0,0 +1,46 @@
package feragstring
import "fmt"
type ProductionDrop struct {
FeragMessage
agentName string
numberOfCopies int
}
func (pd *ProductionDrop) NumberOfCopies() string {
return fmt.Sprintf("+13%05d", pd.numberOfCopies)
}
func (pd *ProductionDrop) SetNumberOfCopies(numberOfCopies int) {
pd.numberOfCopies = numberOfCopies
}
func (pd *ProductionDrop) AgentName() string {
return fmt.Sprintf("+12%-10s", pd.agentName)
}
func (pd *ProductionDrop) SetAgentName(agentName string) {
pd.agentName = agentName
}
func NewProductionDrop() *ProductionDrop {
pd := ProductionDrop{
FeragMessage: FeragMessage{
messageStart: "2403",
messageEnd: "!",
},
}
return &pd
}
func (pd *ProductionDrop) Payload() string {
data := pd.AgentName()
data += pd.NumberOfCopies()
return data
}
func (pd *ProductionDrop) Message() string {
message := pd.FeragMessage.MessageTemplate()
return message(&pd.FeragMessage, pd.Payload())
}