Added comments to Route List. Fixes #7
This commit is contained in:
parent
ad5a1ca400
commit
b8b1e0ca05
2 changed files with 19 additions and 1 deletions
|
@ -2,6 +2,8 @@ package feragstring
|
|||
|
||||
import "fmt"
|
||||
|
||||
// RouteListEntry is the struct for one route entry in the
|
||||
// list of routes
|
||||
type RouteListEntry struct {
|
||||
FeragMessage
|
||||
routeName string
|
||||
|
@ -10,6 +12,7 @@ type RouteListEntry struct {
|
|||
copiesInRoute int
|
||||
}
|
||||
|
||||
// CopiesInRoute returns the formatted number of copies in the route
|
||||
func (r *RouteListEntry) CopiesInRoute() string {
|
||||
if r.copiesInRoute == 0 {
|
||||
return ""
|
||||
|
@ -17,10 +20,13 @@ func (r *RouteListEntry) CopiesInRoute() string {
|
|||
return fmt.Sprintf("+23%06d", r.copiesInRoute)
|
||||
}
|
||||
|
||||
// SetCopiesInRoute set the number of copies in the route
|
||||
func (r *RouteListEntry) SetCopiesInRoute(copiesInRoute int) {
|
||||
r.copiesInRoute = copiesInRoute
|
||||
}
|
||||
|
||||
// RampNumber returns the formatted ramp number. Segment is
|
||||
// returned only if the ramp number is set to a value.
|
||||
func (r *RouteListEntry) RampNumber() string {
|
||||
if r.rampNumber == -1 {
|
||||
return ""
|
||||
|
@ -28,10 +34,13 @@ func (r *RouteListEntry) RampNumber() string {
|
|||
return fmt.Sprintf("+25%02d", r.rampNumber)
|
||||
}
|
||||
|
||||
// SetRampNumber sets the ramp number field to an integer
|
||||
// value. A value of 0 is allowed.
|
||||
func (r *RouteListEntry) SetRampNumber(rampNumber int) {
|
||||
r.rampNumber = rampNumber
|
||||
}
|
||||
|
||||
// RouteCode returns the formatted route code.
|
||||
func (r *RouteListEntry) RouteCode() string {
|
||||
if r.routeCode == 0 {
|
||||
return ""
|
||||
|
@ -39,18 +48,23 @@ func (r *RouteListEntry) RouteCode() string {
|
|||
return fmt.Sprintf("+79%05d", r.routeCode)
|
||||
}
|
||||
|
||||
// SetRouteCode sets the route code field
|
||||
func (r *RouteListEntry) SetRouteCode(routeCode int) {
|
||||
r.routeCode = routeCode
|
||||
}
|
||||
|
||||
// RouteName returns the formatted route name.
|
||||
func (r *RouteListEntry) RouteName() string {
|
||||
return fmt.Sprintf("+11%-13s", r.routeName)
|
||||
}
|
||||
|
||||
// SetRouteName sets the route name field
|
||||
func (r *RouteListEntry) SetRouteName(routeName string) {
|
||||
r.routeName = routeName
|
||||
}
|
||||
|
||||
// NewRouteListEntry instantiates a new Route List Entry
|
||||
// struct and returns a pointer to it.
|
||||
func NewRouteListEntry() *RouteListEntry {
|
||||
rl := RouteListEntry{
|
||||
FeragMessage: FeragMessage{
|
||||
|
@ -62,6 +76,8 @@ func NewRouteListEntry() *RouteListEntry {
|
|||
return &rl
|
||||
}
|
||||
|
||||
// Payload returns the formatted FERAG string
|
||||
// for embedding in the message
|
||||
func (rl *RouteListEntry) Payload() string {
|
||||
data := rl.RouteName()
|
||||
data += rl.RouteCode()
|
||||
|
@ -70,6 +86,8 @@ func (rl *RouteListEntry) Payload() string {
|
|||
return data
|
||||
}
|
||||
|
||||
// Message returns the formatted FERAG string
|
||||
// for the complete route list entry
|
||||
func (rl *RouteListEntry) Message() string {
|
||||
message := rl.FeragMessage.MessageTemplate()
|
||||
return message(&rl.FeragMessage, rl.Payload())
|
||||
|
|
Loading…
Reference in a new issue