
This prevents `brew` self-calls from interacting with the stickiness of HOMEBREW_NO_ANALYTICS being persisted to the brew repo and accidentally disabling analytics permanently when it should have been for just one run, while restoring the stickiness of an explicit user-supplied HOMEBREW_NO_ANALYTICS.
Homebrew's Formula API
This is the (partially) documented public API for Homebrew.
The main class you should look at is the {Formula} class (and classes linked from there). That's the class that's used to create Homebrew formulae (i.e. package descriptions). Assume anything else you stumble upon is private.
You may also find the Formula Cookbook and Ruby Style Guide helpful in creating formulae.
Good luck!