Add NewContent
This commit is contained in:
parent
9df834d927
commit
7764589dd3
26
content.go
26
content.go
@ -1,8 +1,34 @@
|
||||
package atomfeed
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
)
|
||||
|
||||
const (
|
||||
InlineText = iota
|
||||
InlineXHTML
|
||||
InlineOther
|
||||
OutOfLine
|
||||
)
|
||||
|
||||
type Content interface {
|
||||
isContent() bool
|
||||
hasSRC() bool
|
||||
getType() string
|
||||
Check() error
|
||||
}
|
||||
|
||||
func NewContent(contentType int, mediaType string, content any) (Content, error) {
|
||||
switch contentType {
|
||||
case 0:
|
||||
return newInlineTextContent(mediaType, content)
|
||||
case 1:
|
||||
return newInlineXHTMLContent(mediaType, content)
|
||||
case 2:
|
||||
return newInlineOtherContent(mediaType, content)
|
||||
case 3:
|
||||
return newOutOfLineContent(mediaType, content)
|
||||
default:
|
||||
return nil, fmt.Errorf("%v is not a valid text type", contentType)
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user