Initial commit
This commit is contained in:
commit
0f717cd2af
16 changed files with 574 additions and 0 deletions
63
ferag.go
Normal file
63
ferag.go
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
package feragstring
|
||||
|
||||
const (
|
||||
dateInputFormatISO = "2006-01-02"
|
||||
dateOutputFormat = "060102"
|
||||
linebreak = "\r\n"
|
||||
)
|
||||
|
||||
type FeragString struct {
|
||||
TitleInfo *TitleInfo
|
||||
TitleEnd *TitleEnd
|
||||
ProductReferences []*ProductReference
|
||||
ProductReferencesNr int
|
||||
RouteListEntries []*RouteListEntry
|
||||
RouteListEntryCount int
|
||||
}
|
||||
|
||||
func NewFeragString() *FeragString {
|
||||
fs := FeragString{
|
||||
TitleInfo: NewTitleInfo(),
|
||||
TitleEnd: NewTitleEnd(),
|
||||
}
|
||||
return &fs
|
||||
}
|
||||
|
||||
func (fs *FeragString) SetTitleName(titleName string) {
|
||||
fs.TitleInfo.SetTitleName(titleName)
|
||||
fs.TitleEnd.SetTitleName(titleName)
|
||||
}
|
||||
|
||||
func (fs *FeragString) PrintOut() string {
|
||||
info := fs.TitleInfo.Message()
|
||||
|
||||
for _, pr := range fs.ProductReferences {
|
||||
info += pr.Message()
|
||||
}
|
||||
|
||||
for _, rl := range fs.RouteListEntries {
|
||||
info += rl.Message()
|
||||
}
|
||||
|
||||
info += fs.TitleEnd.Message()
|
||||
return info
|
||||
}
|
||||
|
||||
func (fs *FeragString) AddProductReference(pr *ProductReference) error {
|
||||
fs.ProductReferencesNr++
|
||||
pr.SetProductReferenceNumber(fs.ProductReferencesNr)
|
||||
if pr.productReferenceNumber == 1 && pr.productUsageType == 0 {
|
||||
pr.SetProductUsageType(1)
|
||||
}
|
||||
fs.ProductReferences = append(fs.ProductReferences, pr)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (fs *FeragString) AddRouteListEntry(rl *RouteListEntry) error {
|
||||
fs.RouteListEntryCount++
|
||||
if rl.routeCode == 0 {
|
||||
rl.SetRouteCode(fs.RouteListEntryCount)
|
||||
}
|
||||
fs.RouteListEntries = append(fs.RouteListEntries, rl)
|
||||
return nil
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue