Skip to content

Commit 72937ac

Browse files
committed
ditch yahoo weather
1 parent 372da39 commit 72937ac

File tree

2 files changed

+48
-44
lines changed

2 files changed

+48
-44
lines changed
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#!/usr/bin/env jruby -w
2+
require 'propane'
3+
# Loading XML Data
4+
# by Martin Prout
5+
#
6+
# This example demonstrates how to use loadXML
7+
# to retrieve data from an XML document via a URL
8+
Weather = Struct.new(:location, :weather, :celsius, :fahrenheit)
9+
10+
class NOAAWeather < Propane::App
11+
attr_reader :weather
12+
NOAA = 'KMIA' # NOAA Weather Miami Airport
13+
def setup
14+
sketch_title "NOAA's National Weather Service"
15+
# font = create_font('Times Roman', 26)
16+
# font = create_font('Merriweather-Light.ttf', 28)
17+
# text_font(font)
18+
# The URL for the XML document
19+
20+
fo = "https://w1.weather.gov/xml/current_obs/display.php?stid=%s"
21+
url = format(fo, NOAA)
22+
# Load the XML document
23+
xml = loadXML(url)
24+
@weather = Weather.new(
25+
xml.get_child('location'),
26+
xml.get_child('weather'),
27+
xml.get_child('temp_f'),
28+
xml.get_child('temp_c')
29+
)
30+
end
31+
32+
def draw
33+
background(255)
34+
fill(0)
35+
# Display all the stuff we want to display
36+
text(format("Location: %s", weather.location.get_content), width * 0.15, height * 0.36)
37+
text(format("Temperature: %s Fahrenheit", weather.fahrenheit.get_content), width * 0.15, height * 0.5)
38+
text(format("Temperature: %s Celsius", weather.celsius.get_content), width * 0.15, height * 0.66)
39+
text(format('Weather: %s', weather.weather.get_content), width * 0.15, height * 0.82)
40+
no_loop
41+
end
42+
43+
def settings
44+
size 600, 360
45+
end
46+
end
47+
48+
NOAAWeather.new

processing_app/topics/advanced_data/yahoo_weather.rb

Lines changed: 0 additions & 44 deletions
This file was deleted.

0 commit comments

Comments
 (0)