Skip to content

Commit

Permalink
cloud max %
Browse files Browse the repository at this point in the history
  • Loading branch information
onewheelskyward committed Nov 20, 2015
1 parent 56daf06 commit c0617af
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
8 changes: 7 additions & 1 deletion lib/lita/handlers/forecasts.rb
Original file line number Diff line number Diff line change
Expand Up @@ -191,9 +191,15 @@ def do_the_cloud_thing(forecast, chars)
# O ◎ ]
data = forecast['hourly']['data'].slice(0,23)

max = 0
data.each do |datum|
if datum['cloudCover'] > max
max = datum['cloudCover']
end
end
str = get_dot_str(chars, data, 0, 1, 'cloudCover')

"24h cloud cover |#{str}|"
"24h cloud cover |#{str}| max #{max * 100}%"
end

def do_the_sunrise_thing(forecast)
Expand Down
4 changes: 2 additions & 2 deletions spec/lita/handlers/forecast_io_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@

it '!ansicloud' do
send_message 'ansicloud'
expect(replies.last).to eq('Portland, OR 24h cloud cover |___________▁▁▁▁▁▁▁▁▃▅▅▅|')
expect(replies.last).to eq('Portland, OR 24h cloud cover |___________▁▁▁▁▁▁▁▁▃▅▅▅| max 49.0%')
end

it '!asciitemp' do
Expand Down Expand Up @@ -319,7 +319,7 @@
expect(replies[3]).to eq("Portland, OR 24 hr temps: 28.3°F |\u000306_▁▃\u000310▅▇█\u000303██\u000310██▇▅\u000306▅▃▃▃▃▃▃▁▁▁▁\u0003| 28.4°F Range: 28.3°F - 39.0°F")
expect(replies[4]).to eq("Portland, OR 48h wind direction 4.3 mph|\u000306↓\u000310↙←\u000311↖↑↗\u000308→↘\u000311↓←←←←←←\u000310←←←←←←←\u000306←←←←←\u000302←←←↙↙↙↙↓↓↓\u000306↓↓↓↓↓↓↓↓↙↙\u0003|4.18 mph Range: 1.39 mph - 12.71 mph")
expect(replies[5]).to eq("Portland, OR 8 day sun forecast |\u000308█\u000309▃\u000308▇\u000309▁_\u000307▅\u000309▃\u000307▅\u0003|")
expect(replies[6]).to eq("Portland, OR 24h cloud cover |___________▁▁▁▁▁▁▁▁▃▅▅▅|")
expect(replies[6]).to eq("Portland, OR 24h cloud cover |___________▁▁▁▁▁▁▁▁▃▅▅▅| max 49.0%")
expect(replies[7]).to eq("Portland, OR 48 hr snows |\u000302_______________________▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁_\u0003| max 4.0%")
end

Expand Down

0 comments on commit c0617af

Please sign in to comment.