From: David ‘Bombe’ Roden Date: Sat, 28 May 2016 14:15:35 +0000 (+0200) Subject: Move WindDirection to parent package X-Git-Tag: v2~125 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=eb24c175140ccd8219d1994aac1ba279588c6ace;p=rhynodge.git Move WindDirection to parent package --- 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 index 0000000..ab8b030 --- /dev/null +++ b/src/main/kotlin/net/pterodactylus/rhynodge/webpages/weather/WindDirection.kt @@ -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 + } +} diff --git a/src/main/kotlin/net/pterodactylus/rhynodge/webpages/weather/wettercom/HourState.kt b/src/main/kotlin/net/pterodactylus/rhynodge/webpages/weather/wettercom/HourState.kt index f5ddfc2..cd21a92 100644 --- a/src/main/kotlin/net/pterodactylus/rhynodge/webpages/weather/wettercom/HourState.kt +++ b/src/main/kotlin/net/pterodactylus/rhynodge/webpages/weather/wettercom/HourState.kt @@ -1,6 +1,7 @@ package net.pterodactylus.rhynodge.webpages.weather.wettercom import com.fasterxml.jackson.annotation.JsonProperty +import net.pterodactylus.rhynodge.webpages.weather.WindDirection /** * Container for weather conditions of a single hour. diff --git a/src/main/kotlin/net/pterodactylus/rhynodge/webpages/weather/wettercom/WetterComFilter.kt b/src/main/kotlin/net/pterodactylus/rhynodge/webpages/weather/wettercom/WetterComFilter.kt index 04f38fa..dc33b65 100644 --- a/src/main/kotlin/net/pterodactylus/rhynodge/webpages/weather/wettercom/WetterComFilter.kt +++ b/src/main/kotlin/net/pterodactylus/rhynodge/webpages/weather/wettercom/WetterComFilter.kt @@ -4,6 +4,7 @@ import net.pterodactylus.rhynodge.Filter import net.pterodactylus.rhynodge.State import net.pterodactylus.rhynodge.states.FailedState import net.pterodactylus.rhynodge.states.HtmlState +import net.pterodactylus.rhynodge.webpages.weather.toWindDirection import org.jsoup.nodes.Document import org.jsoup.nodes.Element import java.time.LocalDateTime 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 deleted file mode 100644 index f856815..0000000 --- a/src/main/kotlin/net/pterodactylus/rhynodge/webpages/weather/wettercom/WindDirection.kt +++ /dev/null @@ -1,34 +0,0 @@ -package net.pterodactylus.rhynodge.webpages.weather.wettercom - -/** - * 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 - } -} diff --git a/src/test/kotlin/net/pterodactylus/rhynodge/webpages/weather/wettercom/WetterComFilterTest.kt b/src/test/kotlin/net/pterodactylus/rhynodge/webpages/weather/wettercom/WetterComFilterTest.kt index aa72f3c..75b471a 100644 --- a/src/test/kotlin/net/pterodactylus/rhynodge/webpages/weather/wettercom/WetterComFilterTest.kt +++ b/src/test/kotlin/net/pterodactylus/rhynodge/webpages/weather/wettercom/WetterComFilterTest.kt @@ -4,6 +4,7 @@ import net.pterodactylus.rhynodge.State import net.pterodactylus.rhynodge.filters.ResourceLoader.loadDocument import net.pterodactylus.rhynodge.states.FailedState import net.pterodactylus.rhynodge.states.HtmlState +import net.pterodactylus.rhynodge.webpages.weather.WindDirection import org.hamcrest.MatcherAssert.assertThat import org.hamcrest.Matchers.`is` import org.hamcrest.Matchers.contains diff --git a/src/test/kotlin/net/pterodactylus/rhynodge/webpages/weather/wettercom/WetterComStateTest.kt b/src/test/kotlin/net/pterodactylus/rhynodge/webpages/weather/wettercom/WetterComStateTest.kt index cdab7b6..93667ea 100644 --- a/src/test/kotlin/net/pterodactylus/rhynodge/webpages/weather/wettercom/WetterComStateTest.kt +++ b/src/test/kotlin/net/pterodactylus/rhynodge/webpages/weather/wettercom/WetterComStateTest.kt @@ -1,6 +1,7 @@ package net.pterodactylus.rhynodge.webpages.weather.wettercom import com.fasterxml.jackson.databind.ObjectMapper +import net.pterodactylus.rhynodge.webpages.weather.WindDirection import org.hamcrest.MatcherAssert.assertThat import org.hamcrest.Matchers.`is` import org.junit.Test diff --git a/src/test/kotlin/net/pterodactylus/rhynodge/webpages/weather/wettercom/WetterComTriggerTest.kt b/src/test/kotlin/net/pterodactylus/rhynodge/webpages/weather/wettercom/WetterComTriggerTest.kt index 2205dbb..5cc3f06 100644 --- a/src/test/kotlin/net/pterodactylus/rhynodge/webpages/weather/wettercom/WetterComTriggerTest.kt +++ b/src/test/kotlin/net/pterodactylus/rhynodge/webpages/weather/wettercom/WetterComTriggerTest.kt @@ -1,6 +1,7 @@ package net.pterodactylus.rhynodge.webpages.weather.wettercom import net.pterodactylus.rhynodge.Reaction +import net.pterodactylus.rhynodge.webpages.weather.WindDirection import org.hamcrest.MatcherAssert.assertThat import org.hamcrest.Matchers.`is` import org.hamcrest.Matchers.containsString