Skip to content

Instantly share code, notes, and snippets.

@ryancoughlin
Last active November 15, 2015 17:33
Show Gist options
  • Save ryancoughlin/553f39f625e080ee65e3 to your computer and use it in GitHub Desktop.
Save ryancoughlin/553f39f625e080ee65e3 to your computer and use it in GitHub Desktop.
import Foundation
// Factors
let newSnow = 15 // newSnowMax
let currentWeatherType = "snow" // weather.currently.summary
let temp = 32 // weather.currently.apparentTemperature (factors, wind chill, more accurate)
let wind = 2 // weather.currently.windSpeed
enum NewSnow: Int {
case None, Little, Alot
}
enum WeatherType: String {
case Good, Bad, Decent
}
struct NewSnowAmount {
let amount: Int
var status: NewSnow {
switch amount {
case _ where amount > 10:
return .Alot
case _ where amount > 5:
return .Little
default:
return .None
}
}
init(amount: Int) {
self.amount = amount
}
}
struct WeatherTypeConditions {
let type: String
let points: Float
var foo: WeatherType {
switch type {
case "clear-day", "clear-night", "snow":
return .Good
case "sleet", "wind", "fog", "rain":
return .Bad
default:
return .Decent
}
}
init(type: String, points: Float) {
self.type = type
self.points = points
}
}
let weather = WeatherTypeConditions(type: currentWeatherType, points: 2)
weather.foo
let snow = NewSnowAmount(amount: newSnow)
snow.status
// If conditions are outrageous powder (~8+)
// If conditions are great
// If conditions are OK
// If conditions are terrible (high windchill, rain, or temps below say 15)
// If conditions are start of season (shallow maxBaseDepth and no new snow, warmer tempers) = "Let's hope for snow"
if (snow.status == NewSnow.Alot && weather.foo == WeatherType.Good) {
print("Go out!")
// the output could be a random index from an array of "great" phrases
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment