Extract inner classes, some cleanups
[rhynodge.git] / src / main / kotlin / net / pterodactylus / rhynodge / webpages / weather / wettercom / WindDirection.kt
diff --git a/src/main/kotlin/net/pterodactylus/rhynodge/webpages/weather/wettercom/WindDirection.kt b/src/main/kotlin/net/pterodactylus/rhynodge/webpages/weather/wettercom/WindDirection.kt
new file mode 100644 (file)
index 0000000..6335fe2
--- /dev/null
@@ -0,0 +1,34 @@
+package net.pterodactylus.rhynodge.webpages.weather.wettercom
+
+/**
+ * The direction the wind comes from.
+ *
+ * @author [David ‘Bombe’ Roden](mailto:bombe@pterodactylus.net)
+ */
+enum class WindDirection {
+
+    NONE,
+    NORTH,
+    NORTHEAST,
+    EAST,
+    SOUTHEAST,
+    SOUTH,
+    SOUTHWEST,
+    WEST,
+    NORTHWEST
+
+}
+
+fun String.toWindDirection(): WindDirection {
+    return when (this) {
+        "N" -> WindDirection.NORTH
+        "NE" -> WindDirection.NORTHEAST
+        "E" -> WindDirection.EAST
+        "SE" -> WindDirection.SOUTHEAST
+        "S" -> WindDirection.SOUTH
+        "SW" -> WindDirection.SOUTHWEST
+        "W" -> WindDirection.WEST
+        "NW" -> WindDirection.NORTHWEST
+        else -> WindDirection.NONE
+    }
+}