Permalink
Browse files

Add rainfall display

  • Loading branch information...
pshved committed Jul 23, 2013
1 parent e567f25 commit 0991e920f47c21f676403cf6c8c8e4f824733757
Showing with 64 additions and 1 deletion.
  1. +45 −0 client/font/specific.simpleglyphs
  2. +19 −1 contrib/morning_room.rb
@@ -17,3 +17,48 @@
101
010
140 0 1 ...
000
141 0 7 ...
111
142 0 7 ...
111
111
143 0 7 ...
111
111
111
144 0 7 ...
111
111
111
111
145 0 7 ...
111
111
111
111
111
146 0 7 ...
111
111
111
111
111
111
147 0 7 ...
111
111
111
111
111
111
111
View
@@ -95,7 +95,25 @@ def prediction_string(arrival_times, options)
# And the current temperature, too (it's in the first cell).
weather_now = doc['data'].first['parameters'].first['temperature'].first['value'][0]
weather_str = "#{130.chr}#{weather_now}#{129.chr}#{weather_later}"
# Get rain conditions
begin
conditions = doc['data'].first['parameters'].first['weather'].first['weather-conditions'][time_index]
rain = (conditions['value'] || []).find {|c| c['weather-type'] == 'rain'}
if rain
coverage_map = {
# Todo: uncover more rainfall phrases!
'slight chance' => 141.chr,
'chance' => 143.chr,
'likely' => 146.chr,
}
rain_str = coverage_map[rain['coverage']]
end
rescue => e
$stderr.puts "Weather error received: #{e}\n#{e.backtrace.join("\n")}"
rain_str = ''
end
weather_str = "#{130.chr}#{weather_now}#{129.chr}#{weather_later}#{rain_str}"
rescue => e
# We rescue on various key errors, and inavailability. Turn this on for
# debugging.

0 comments on commit 0991e92

Please sign in to comment.