[go: up one dir, main page]

Skip to content

Commit

Permalink
fix 16-point direction
Browse files Browse the repository at this point in the history
  • Loading branch information
siph committed Sep 8, 2023
1 parent 0a2f982 commit 6c9feae
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion wt_fetch.nu
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,15 @@ def match_moon_phase_icon [phase: string] {

# Match a wind direction (SE, etc...) to an icon (↘ etc...).
def match_direction_icon [direction: string] {
match ($direction | str replace -a " " "" | str downcase) {

# Reduce 16-point direction to 8-point.
let eight_point = (
if (($direction | str length) == 3) {
$direction | str substring 1..
} else { $direction }
)

match ($eight_point | str replace -a " " "" | str downcase) {
"s" => "",
"sw" => "",
"w" => "",
Expand Down Expand Up @@ -305,6 +313,14 @@ def test_moon_phase_match [] {
assert equal $result $expected
}

#[test]
def test_wind_direction_sixteen_point [] {
let expected = ""
let result = match_direction_icon "ENE"

assert equal $result $expected
}

#[test]
def test_wind_direction_unknown [] {
let expected = "?"
Expand Down

0 comments on commit 6c9feae

Please sign in to comment.