inital commit
This commit is contained in:
46
enums.go
Normal file
46
enums.go
Normal file
@@ -0,0 +1,46 @@
|
||||
package fa
|
||||
|
||||
import "strings"
|
||||
|
||||
// Rating reflects the submission's content rating as displayed on the page.
|
||||
// FA uses three buckets. Unknown values from future site changes are preserved
|
||||
// verbatim rather than mapped to an "Unknown" constant, so parser drift
|
||||
// surfaces in field values, not in panics.
|
||||
type Rating string
|
||||
|
||||
const (
|
||||
RatingGeneral Rating = "General"
|
||||
RatingMature Rating = "Mature"
|
||||
RatingAdult Rating = "Adult"
|
||||
)
|
||||
|
||||
// ParseRating normalises a rating string (case-insensitive) into one of the
|
||||
// known constants, or returns it lower-cased-and-titled verbatim if unknown.
|
||||
func ParseRating(s string) Rating {
|
||||
switch strings.ToLower(strings.TrimSpace(s)) {
|
||||
case "general", "g":
|
||||
return RatingGeneral
|
||||
case "mature", "m":
|
||||
return RatingMature
|
||||
case "adult", "a", "explicit", "e":
|
||||
return RatingAdult
|
||||
default:
|
||||
return Rating(strings.TrimSpace(s))
|
||||
}
|
||||
}
|
||||
|
||||
// Category is FA's "Category" metadata field (e.g. "Artwork (Digital)",
|
||||
// "Story", "Music"). Stored as the raw string so unknown categories survive.
|
||||
type Category string
|
||||
|
||||
// Type is FA's "Type" metadata field. Often parallels Category for visual
|
||||
// art ("Digital", "Traditional", "Photography", ...) and differs for other
|
||||
// media. Stored raw.
|
||||
type Type string
|
||||
|
||||
// Species is FA's "Species" metadata field (e.g. "Wolf", "Dragon", "Fox").
|
||||
// Free-form on the site.
|
||||
type Species string
|
||||
|
||||
// Gender is FA's "Gender" metadata field (e.g. "Male", "Female", "Any").
|
||||
type Gender string
|
||||
Reference in New Issue
Block a user