From 5c415c5aacfce727b70f0c75c692b02e93dece87 Mon Sep 17 00:00:00 2001 From: Oliver Jakoubek Date: Fri, 29 May 2020 14:54:45 +0200 Subject: [PATCH] Added comment to title info --- title_info.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/title_info.go b/title_info.go index c54e540..3bb1248 100644 --- a/title_info.go +++ b/title_info.go @@ -5,6 +5,7 @@ import ( "time" ) +// TitleInfo is the struct for the FERAG title info message (%2440) type TitleInfo struct { FeragMessage printObjectName string @@ -16,14 +17,18 @@ type TitleInfo struct { showEmptyAdditionalInfo bool } +// ShowEmptyAdditionalInfo sets the flag showEmptyAdditionalInfo to true. +// The segment additional info is then shown even it is empty (+08). func (ti *TitleInfo) ShowEmptyAdditionalInfo() { ti.showEmptyAdditionalInfo = true } +// SetPrintObjectName sets the printObjectName segment (+93) func (ti *TitleInfo) SetPrintObjectName(printObjectName string) { ti.printObjectName = printObjectName } +// AdditionalInfo returns the additional info segment (+08) FERAG-formatted func (ti *TitleInfo) AdditionalInfo() string { if ti.additionalInfo == "" && ti.showEmptyAdditionalInfo == false { return "" @@ -31,10 +36,12 @@ func (ti *TitleInfo) AdditionalInfo() string { return fmt.Sprintf("+08%-50s", ti.additionalInfo) } +// SetAdditionalInfo sets the additional info segment (+08) func (ti *TitleInfo) SetAdditionalInfo(additionalInfo string) { ti.additionalInfo = additionalInfo } +// PrintObjectColor returns the print object color segment (+94) FERAG-formatted func (ti *TitleInfo) PrintObjectColor() string { if ti.printObjectColor == "" { return "" @@ -42,10 +49,12 @@ func (ti *TitleInfo) PrintObjectColor() string { return fmt.Sprintf("+94%-8s", ti.printObjectColor) } +// SetPrintObjectColor sets the print object color segment (+94) func (ti *TitleInfo) SetPrintObjectColor(printObjectColor string) { ti.printObjectColor = printObjectColor } +// CountryCode returns the country code segment (+97) FERAG-formatted func (ti *TitleInfo) CountryCode() string { if ti.countryCode == "" { return "" @@ -53,10 +62,12 @@ func (ti *TitleInfo) CountryCode() string { return fmt.Sprintf("+97%-2s", ti.countryCode) } +// SetCountryCode set the country code segment (+97) func (ti *TitleInfo) SetCountryCode(countryCode string) { ti.countryCode = countryCode } +// SetPublicationDate sets the publication date segment (+95) func (ti *TitleInfo) SetPublicationDate(publicationDateString string) { parsedDate, err := time.Parse(dateInputFormatISO, publicationDateString) if err != nil { @@ -65,6 +76,7 @@ func (ti *TitleInfo) SetPublicationDate(publicationDateString string) { ti.publicationDate = parsedDate } +// PublicationDate returns the publication date segment (+95) FERAG-formatted func (ti *TitleInfo) PublicationDate() string { if ti.publicationDate.IsZero() { return "" @@ -72,11 +84,13 @@ func (ti *TitleInfo) PublicationDate() string { return fmt.Sprintf("+95%-6s", ti.publicationDate.Format(dateOutputFormat)) } +// Message returns the complete FERAG-formatted message for title info func (ti *TitleInfo) Message() string { message := ti.FeragMessage.MessageTemplate() return message(&ti.FeragMessage, ti.Payload()) } +// Payload returns the inner content for title info to be included in Message() func (ti *TitleInfo) Payload() string { data := ti.PrintObjectName() data += ti.TitleName() @@ -87,6 +101,7 @@ func (ti *TitleInfo) Payload() string { return data } +// PrintObjectName returns the print object name segment (+93) FERAG-formatted func (ti *TitleInfo) PrintObjectName() string { if ti.printObjectName == "" { return "" @@ -94,14 +109,17 @@ func (ti *TitleInfo) PrintObjectName() string { return fmt.Sprintf("+93%-12s", ti.printObjectName) } +// TitleName returns the title name segment (+40) FERAG-formatted func (ti *TitleInfo) TitleName() string { return fmt.Sprintf("+40%-8s", ti.titleName) } +// SetTitleName sets the title name segment (+40) func (ti *TitleInfo) SetTitleName(titleName string) { ti.titleName = titleName } +// NewTitleInfo returns a new TitleInfo struct func NewTitleInfo() *TitleInfo { t := TitleInfo{ FeragMessage: FeragMessage{"2440", "!"},