Move WindDirection to parent package
[rhynodge.git] / src / main / kotlin / net / pterodactylus / rhynodge / webpages / weather / WindDirection.kt
diff --git a/src/main/kotlin/net/pterodactylus/rhynodge/webpages/weather/WindDirection.kt b/src/main/kotlin/net/pterodactylus/rhynodge/webpages/weather/WindDirection.kt
new file mode 100644 (file)
index 0000000..ab8b030
--- /dev/null
@@ -0,0 +1,34 @@
+package net.pterodactylus.rhynodge.webpages.weather
+
+/**
+ * The direction the wind comes from.
+ *
+ * @author [David ‘Bombe’ Roden](mailto:bombe@pterodactylus.net)
+ */
+enum class WindDirection(val arrow: String) {
+
+    NONE("↺"),
+    NORTH("↓"),
+    NORTHEAST("↙"),
+    EAST("←"),
+    SOUTHEAST("↖"),
+    SOUTH("↑"),
+    SOUTHWEST("↗"),
+    WEST("→"),
+    NORTHWEST("↘")
+
+}
+
+fun String.toWindDirection(): WindDirection {
+    return when (this) {
+        "N" -> WindDirection.NORTH
+        "NO" -> WindDirection.NORTHEAST
+        "O" -> WindDirection.EAST
+        "SO" -> WindDirection.SOUTHEAST
+        "S" -> WindDirection.SOUTH
+        "SW" -> WindDirection.SOUTHWEST
+        "W" -> WindDirection.WEST
+        "NW" -> WindDirection.NORTHWEST
+        else -> WindDirection.NONE
+    }
+}