diff --git a/ferag_message.go b/ferag_message.go index 23b9121..72669bb 100644 --- a/ferag_message.go +++ b/ferag_message.go @@ -5,6 +5,8 @@ import ( "strings" ) +// FeragMessage is the struct for the "abstract" message. +// It is meant to be embedded into the real message structs. type FeragMessage struct { messageStart string messageEnd string @@ -18,8 +20,12 @@ func (fm *FeragMessage) getMessageEnd() string { return fmt.Sprintf("%s", fm.messageEnd) } +// MessageTemplateFunc is a func type for the generating the +// FERAG-formatted message. type MessageTemplateFunc func(*FeragMessage, string) string +// MessageTemplate returns a MessageTemplateFunc - to be called +// from within the "real" message structs. func (fm *FeragMessage) MessageTemplate() MessageTemplateFunc { return func(fm *FeragMessage, s string) string { message := fm.getMessageStart() diff --git a/title_end.go b/title_end.go index 978fbd9..2e60a58 100644 --- a/title_end.go +++ b/title_end.go @@ -2,19 +2,23 @@ package feragstring import "fmt" +// TitleEnd is the struct for the FERAG title info message (%2441) type TitleEnd struct { FeragMessage titleName string } -func (ti *TitleEnd) PrintObjectName() string { +// TitleName returns the title name segment (+40) FERAG-formatted +func (ti *TitleEnd) TitleName() string { return fmt.Sprintf("+40%-8s", ti.titleName) } +// SetTitleName sets the title name segment (+40) func (ti *TitleEnd) SetTitleName(titleName string) { ti.titleName = titleName } +// NewTitleEnd returns a new TitleEnd struct func NewTitleEnd() *TitleEnd { t := TitleEnd{ FeragMessage: FeragMessage{ @@ -25,8 +29,9 @@ func NewTitleEnd() *TitleEnd { return &t } +// Message returns the complete FERAG-formatted message for title end func (ti *TitleEnd) Message() string { message := ti.FeragMessage.MessageTemplate() - payload := fmt.Sprintf("+40%-8s", ti.titleName) + payload := ti.TitleName() return message(&ti.FeragMessage, payload) }