Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

StevenC Single Purpose #7

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions SCreadme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
This is a simple application using the sinatra gem. The main purpose to display the current weather. Depending the weather it will display a certain image. A sun with a smiley face when it is sunny and vice versa. When one clicks on the image, it goes to theweatherchannel.com and shows the five day weather forecast (New York, New York). In order to achieve this, I also used a weather gem.

gem install weather-api

Stuff about the api
https://rubygems.org/gems/weather-api

There are several bugs at the moment. It is not correctly displaying text such as the temperature and the date.

The link to the app is http://sapp.herokuapp.com/

Unforunately, it is not working.

![Alt Text](http://emojipedia.org/wp-content/uploads/2013/07/45-worried-face.png)
43 changes: 43 additions & 0 deletions StevenCsinglepurposeapp.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
require 'sinatra'
require 'rubygems'
require 'weather-api'


response = Weather.lookup(2347591)

location = response.title
temp = response.condition.temp
condition = response.condition.text
condition.downcase!

get '/' do

"The #{location} is"

#Here is a condition. Checks out the temperature and displays a message.

if temp >= 80
"Right now it is #{temp} degrees. Pretty hot, you might want to go to the beach."
elsif temp <= 80 || temp >= 55
"Right now it is #{temp} degrees. Nice temperature out here. Take a nice stoll in the park"
elsif temp <= 54 || temp >= 40
"Right now it is #{temp} degrees. Pretty chilly out here. Sweater time."
elsif temp <=39 || temp >= 20
"Right now it is #{temp} degrees. Man, it's cold out here. Use that awesome coat you bought."
else
"Right now it is #{temp} degrees. Why are you out here again?"
end

#Here is a condition. Checks out the appearance of the weather and displays a message.

if condition.include? "sunny"
"Today's weather is #{condition}. Nice."
erb :smiles
else
"Today's weather is #{condition}. I wish it was sunny :("
erb :notsmiles
end
end

require './app'
run Sinatra::Application
5 changes: 5 additions & 0 deletions views/notsmiles.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

<h3>Click the image to see the 5 day forecast<h/3>

<a href = "http://www.weather.com/weather/5-day/USNY0996"><img src ="http://images.clipartpanda.com/sad-sun-clip-art-toonvectors-324-940.jpg" align = "top">
</a>
2 changes: 2 additions & 0 deletions views/smiles.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<h3>Click the image to see the 5 day forecast<h/3>
<a href = "http://www.weather.com/weather/5-day/USNY0996"><img src ="http://www.vector-eps.com/wp-content/gallery/sun-smiley-face-expressions-vector/sun-smiley-face-expression-vector1.jpg" align = "middle"> </a>