Added String() implementation to Bible reference type.
This commit is contained in:
parent
c70bcceeed
commit
aa5615814a
1 changed files with 29 additions and 0 deletions
|
|
@ -7,6 +7,7 @@ import (
|
|||
"io"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
|
|
@ -86,6 +87,34 @@ func (r *BibleRef) Code() string {
|
|||
return ""
|
||||
}
|
||||
|
||||
func (r *BibleRef) String() string {
|
||||
sb := &strings.Builder{}
|
||||
if name, ok := titles[r.Code()]; ok {
|
||||
sb.WriteString(name)
|
||||
} else {
|
||||
sb.WriteString("???")
|
||||
}
|
||||
sb.WriteString(" ")
|
||||
if r.Chapter > 0 {
|
||||
sb.WriteString(strconv.Itoa(r.Chapter))
|
||||
}
|
||||
if r.Verse > 0 {
|
||||
sb.WriteString(strconv.Itoa(r.Verse))
|
||||
} else {
|
||||
if r.Verses.Start > 0 {
|
||||
sb.WriteString(strconv.Itoa(r.Verses.Start))
|
||||
if r.Verses.Stop > 0 {
|
||||
|
||||
} else {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return sb.String()
|
||||
}
|
||||
|
||||
type Metadata struct {
|
||||
ID string `json:"id"`
|
||||
Name string `json:"name"`
|
||||
|
|
|
|||
Loading…
Reference in a new issue