package lulu import ( "bytes" "encoding" "fmt" ) //go:generate go run github.com/yawnak/string-enumer -t TrimSize -t ColorType -t Quality -t Binding -t Paper -t Finish -t Linen -t Foil --text -o ./pkgid_gen.go . // PkgId is a pod_package_id which represents the manufacturing options // of a printable. type PkgId struct { TrimSize ColorType Quality Binding Paper Finish Linen Foil } func (p PkgId) MarshalText() ([]byte, error) { return []byte(fmt.Sprintf("%s.%s.%s.%s.%s.%s%s%s", p.TrimSize, p.ColorType, p.Quality, p.Binding, p.Paper, p.Finish, p.Linen, p.Foil)), nil } func (p *PkgId) UnmarshalText(text []byte) error { s := string(text) parts := bytes.Split(text, []byte(".")) if len(parts) != 6 { return fmt.Errorf("malformed pod_package_id %q: has %d dot-separated fields; want 6", s, len(parts)) } cover := parts[5] if len(cover) != 3 { return fmt.Errorf("malformed pod_package_id %q: finish/linen/foil suffix must be 3 characters", s) } for i, field := range []encoding.TextUnmarshaler{&p.TrimSize, &p.ColorType, &p.Quality, &p.Binding, &p.Paper} { if err := field.UnmarshalText(parts[i]); err != nil { return err } } for i, field := range []encoding.TextUnmarshaler{&p.Finish, &p.Linen, &p.Foil} { if err := field.UnmarshalText([]byte{cover[i]}); err != nil { return err } } return nil } // TrimSize is the final dimensions of the pages after the bleed margins // are trimmed off. type TrimSize string const ( Pocketbook TrimSize = "0425X0687" Novella TrimSize = "0500X0800" Digest TrimSize = "0550X0850" A5 TrimSize = "0583X0827" UsTrade TrimSize = "0600X0900" Royal TrimSize = "0614X0921" Comic TrimSize = "0663X1025" SmallSquare TrimSize = "0750X0750" Executive TrimSize = "0700X1000" CrownQuatro TrimSize = "0744X0968" Square TrimSize = "0850X0850" A4 TrimSize = "0827X1169" UsLetter TrimSize = "0850X1100" Landscape TrimSize = "0900X0700" UsLetterLandscape TrimSize = "1100X0850" A4Landscape TrimSize = "1169X0827" ) // ColorType is the color mode of the printer. type ColorType string const ( Mono ColorType = "BW" Color ColorType = "FC" ) // Quality is the print quality. type Quality string const ( Premium Quality = "PRE" Standard Quality = "STD" ) type Binding string const ( Perfect Binding = "PB" Coil Binding = "CO" SaddleStitch Binding = "SS" CaseWrap Binding = "CW" LinenWrap Binding = "LW" WireO Binding = "WO" ) // Paper is the weight/thickness and hue of the paper. type Paper string const ( P60UncoatedWhite Paper = "060UW444" P60UncoatedCream Paper = "060UC444" P70CoatedWhite Paper = "070CW460" P80CoatedWhite Paper = "080CW444" P100CoatedWhite Paper = "100CW" ) // Finish is the surface finish of the cover. type Finish string const ( Gloss Finish = "G" Matte Finish = "M" Unlaminated Finish = "U" ) // Linen is the color of the linen-wrapped cover, if applicable. type Linen string const ( RedLinen Linen = "R" NavyLinen Linen = "N" BlackLinen Linen = "B" GrayLinen Linen = "G" TanLinen Linen = "T" ForestLinen Linen = "F" InteriorCoverPrint Linen = "I" NoLinen Linen = "X" ) // Foil is the color of the foil stamping, if applicable. type Foil string const ( GoldFoil Foil = "G" BlackFoil Foil = "B" WhiteFoil Foil = "W" NoFoil Foil = "X" )