-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathgenerate_airports_page.rb
More file actions
58 lines (43 loc) · 1.3 KB
/
generate_airports_page.rb
File metadata and controls
58 lines (43 loc) · 1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
require './airport'
def start_of_page
html = '<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Airport Chart</title>
<link rel="stylesheet" href="http://netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.css">
<link href="http://netdna.bootstrapcdn.com/font-awesome/3.2.1/css/font-awesome.css" rel="stylesheet">
<link rel="stylesheet" href="css/weather.css">
<link rel="stylesheet" href="css/airports.css">
</head>
<body>
<div class="container">'
return html
end
def end_of_page
final_part = '</div></body></html>'
return final_part
end
def html_for_airport(airport)
current_delay = airport.delay
html = '<div class="col-md-3 chart well">'
html << "<h2>#{airport.code}</h2>"
html << '<p class="text-muted temperature">' + airport.temperature.to_s + '° F</p>'
if current_delay < 15
airport_class = 'on-time'
elsif current_delay < 30
airport_class = 'delayed'
else
airport_class = 'nightmare'
end
html << '<i class="airport icon-plane ' + airport_class + '"></i>'
html << "</div>"
return html
end
puts start_of_page
['ORD', 'LAX', 'BOS', 'MDW', 'PDX', 'AUS'].each do |airport_code|
airport = Airport.new
airport.code = airport_code
puts html_for_airport(airport)
end
puts end_of_page