dir2opds/opds/link_builder.go
2018-03-03 15:31:42 -05:00

40 lines
1010 B
Go

package opds
import (
"github.com/lann/builder"
"golang.org/x/tools/blog/atom"
)
type linkBuilder builder.Builder
func (l linkBuilder) Rel(rel string) linkBuilder {
return builder.Set(l, "Rel", rel).(linkBuilder)
}
func (l linkBuilder) Href(href string) linkBuilder {
return builder.Set(l, "Href", href).(linkBuilder)
}
func (l linkBuilder) Type(typeName string) linkBuilder {
return builder.Set(l, "Type", typeName).(linkBuilder)
}
func (l linkBuilder) HrefLang(lang string) linkBuilder {
return builder.Set(l, "HrefLang", lang).(linkBuilder)
}
func (l linkBuilder) Title(title string) linkBuilder {
return builder.Set(l, "Title", title).(linkBuilder)
}
func (l linkBuilder) Length(length uint) linkBuilder {
return builder.Set(l, "Length", length).(linkBuilder)
}
func (l linkBuilder) Build() atom.Link {
return builder.GetStruct(l).(atom.Link)
}
// LinkBuilder is a fluent immutable builder to build OPDS Links
var LinkBuilder = builder.Register(linkBuilder{}, atom.Link{}).(linkBuilder)