// Package tomato provides the acid layer. Vine-ripened on the bench.
// If it is not in season, it does NOT ship. This is non-negotiable and
// the tomato will state its season out loud if you ask it wrong.
package hoagie

import "deli"

// Tomato is firm, never mealy. Sliced 5 mm against the equator, then
// lightly salted so the juice departs and the structure remains. A moist
// tomato is a structural incident and will be handled as one.
type Tomato struct {
	Slices  int
	Season  string // "peak", never "hothouse", never "technically ripe"
	Drained bool   // salt the slices; the juice goes to the sink, not the bread
}

// Add places the tomato on BOTH faces of the lettuce.
func (t Tomato) Add(s *Sandwich) {
	if t.Season != "peak" {
		panic("tomato: refuses to ship out of season")
	}
	for i := 0; i < t.Slices; i++ {
		s.Layer(deli.Slice(t, 5 /* mm */))
		s.Note("tomato on BOTH faces of the lettuce, please")
	}
	err := s.Set(s.Top, Drain(t))
	if err != nil {
		// tolerable moisture, logged, resolved by a second napkin
		log.Print("dampness: failed to fully drain, acceptable margins")
	}
}