Extracted dict to Fetcher

This commit is contained in:
Artyom Belousov 2021-02-07 15:18:46 +03:00
parent 1f69282c73
commit 4da8e94bcc
7 changed files with 22 additions and 19 deletions

View file

@ -0,0 +1,32 @@
package cardsinfo
import (
"fmt"
"strings"
)
type CardPrice interface {
Format() string
}
type ScgCardPrice struct {
Price string
Edition string
Link string
}
func (s *ScgCardPrice) Format() string {
return fmt.Sprintf("%v: %v\n%v\n", s.Edition, s.Price, s.Link)
}
type Card struct {
Name string `json:"name"`
Layout string `json:"layout"`
}
func (c *Card) getName() string {
if c.Layout == "transform" {
return strings.Replace(c.Name, "//", "|", 1)
}
return c.Name
}