From a20f932b6fb89f18c3db41d86db3cf6c320c7a74 Mon Sep 17 00:00:00 2001 From: Dimitris Date: Thu, 31 Aug 2017 18:07:35 +0300 Subject: [PATCH 1/3] added sunrise and sunset times on the gem --- lib/openweather2/weather.rb | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/openweather2/weather.rb b/lib/openweather2/weather.rb index 1da3d57..1fa9966 100644 --- a/lib/openweather2/weather.rb +++ b/lib/openweather2/weather.rb @@ -2,7 +2,8 @@ module Openweather2 class Weather attr_reader :city, :longitude, :latitude, :pressure, :humidity, :clouds, - :temperature, :min_temperature, :max_temperature, :wind_speed, :wind_angle + :temperature, :min_temperature, :max_temperature, :wind_speed, + :wind_angle, :sunrise, :sunset def initialize(json) @city = json['name'] @@ -16,6 +17,8 @@ def initialize(json) @clouds = json['clouds']['all'] @wind_speed = json['wind']['speed'] @wind_angle = json['wind']['deg'] + @sunrise = json['sys']['sunrise'] + @sunset = json['sys']['sunset'] end end -end \ No newline at end of file +end From 157e3e7d77344c6901686ce7ee643aa247206ea4 Mon Sep 17 00:00:00 2001 From: Dimitris Date: Thu, 31 Aug 2017 18:24:23 +0300 Subject: [PATCH 2/3] Parsed time bigints to local computer time --- lib/openweather2/weather.rb | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/openweather2/weather.rb b/lib/openweather2/weather.rb index 1fa9966..804068b 100644 --- a/lib/openweather2/weather.rb +++ b/lib/openweather2/weather.rb @@ -1,6 +1,5 @@ module Openweather2 class Weather - attr_reader :city, :longitude, :latitude, :pressure, :humidity, :clouds, :temperature, :min_temperature, :max_temperature, :wind_speed, :wind_angle, :sunrise, :sunset @@ -17,8 +16,8 @@ def initialize(json) @clouds = json['clouds']['all'] @wind_speed = json['wind']['speed'] @wind_angle = json['wind']['deg'] - @sunrise = json['sys']['sunrise'] - @sunset = json['sys']['sunset'] + @sunrise = Time.at(json['sys']['sunrise']) + @sunset = Time.at(json['sys']['sunset']) end end end From 9ca3a88352da714958760e1ccb85e23ad4510c80 Mon Sep 17 00:00:00 2001 From: Dimitris Date: Thu, 31 Aug 2017 18:44:57 +0300 Subject: [PATCH 3/3] added the sunrise and sunset functions to the README.md --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 046d5cc..362367c 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,8 @@ Also you can get some data on the gem response: * Clouds * Wind speed * Wind angle +* Sunrise Time +* Sunset Time You can get your APP ID from the OpenWeatherMap website. @@ -90,4 +92,3 @@ Contributors: ## License The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT). -