From b8b1e0ca056a07e3f424a61ae9532f77b757c68e Mon Sep 17 00:00:00 2001 From: Oliver Jakoubek Date: Mon, 6 Jul 2020 20:43:58 +0200 Subject: [PATCH] Added comments to Route List. Fixes #7 --- route_end.go | 2 +- route_list.go | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/route_end.go b/route_end.go index a43be65..db73eb8 100644 --- a/route_end.go +++ b/route_end.go @@ -18,7 +18,7 @@ func (re *RouteEnd) SetRouteName(routeName string) { re.routeName = routeName } -// NewRouteEnd instantiates a new Route End +// NewRouteEnd instantiates a new Route End // struct and returns a pointer to it. func NewRouteEnd() *RouteEnd { re := RouteEnd{ diff --git a/route_list.go b/route_list.go index e437722..19298ab 100644 --- a/route_list.go +++ b/route_list.go @@ -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())