type EpisodeContainer interface {
// Returns true if this EpisodeContainer is equivalent or a superset of the given EpisodeContainer
ContainsEpisodes(EpisodeContainer) bool
+ // Returns a channel meant for iterating with for/range.
+ // Sends all contained episodes in order.
+ Episodes() chan Episode
}
type Formatter interface {
}
// Converts the Episode into AniDB API episode format.
-func (ep *Episode) String() string {
+func (ep Episode) String() string {
return ep.Format(1)
}
return scale(ep.Number)
}
+func (ep *Episode) Episodes() chan Episode {
+ ch := make(chan Episode, 1)
+ if ep != nil {
+ ch <- *ep
+ }
+ close(ch)
+ return ch
+}
+
// Returns true if ec is an Episode and is identical to this episode,
// or if ec is a single episode EpisodeRange / EpisodeList that
// contain only this episode.
return false
}
-func (ep *Episode) Format(width int) string {
+func (ep Episode) Format(width int) string {
if ep.Part < 0 { // whole episode
return fmt.Sprintf("%s%0"+strconv.Itoa(width)+"d", ep.Type, ep.Number)
}