accuweather 0.2.2 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1549fa0380c0b2be4d6cf1ff807a1538bcd7db79
4
- data.tar.gz: 3efea0be0d68e3fee8c74d0e6913bda363dc09c2
3
+ metadata.gz: 1533c3703a8db32ad90d2a937d68deb18692f58b
4
+ data.tar.gz: 43886b874f4125eb407c7308971af3bb4e80faea
5
5
  SHA512:
6
- metadata.gz: 4d19950635990297ebca3b83f59adb867f73b2d7baee1029ed799ec87cef39872df819ddf3a4c05e6351f320905ec7bb1bb96e1c9626f463dbef536cf91b7f80
7
- data.tar.gz: 93a6ead68387820cb2cee8496f7f622b960675ba85b91f4d78fb86f1d1dee38e47c77d56bf2fd85c4722bb1ab864e6efdb0281e5aadf5cce30d6bc36187538f9
6
+ metadata.gz: 34a38d57fd3bf290a3a448f3f20fdfd5b05f64cebb03fad4aa94fb93c56c5d0d3f7ef732027d1f46a73564eeb7aec5e45fbcd8672cf76ed708edc7a4f72c1496
7
+ data.tar.gz: afb242549b49240ff5e9ff04b227179255a1ded1aa53e9f24ce23f25e00d36d8c8a87478a6676ab86580837bcae8172b921ec78ee51ca5fd980ffcad5006c826
data/README.md CHANGED
@@ -4,6 +4,8 @@ A simple wrapper around the accuweather web API written in Ruby
4
4
 
5
5
  Get weather information for cities around the world. Includes current current conditions for temperature, pressure and humidity. Forecasts include temperature highs, lows, "real feels", UV, wind speed and direction, rain, snow, ice probabilities and amounts. The web API returns seven days of forecasts with estimates for both day and nighttime.
6
6
 
7
+ Also includes local times for the rise and set of celestial bodies in our solar system including the sun, moon, mercury, venus, mars, jupiter, saturn, uranus, neptune and pluto.
8
+
7
9
  ## Installation
8
10
 
9
11
  Add this line to your application's Gemfile:
@@ -96,6 +98,17 @@ Accuweather.get_conditions(location_id: 'cityId:53286').local.to_s
96
98
  # => "city: Vancouver, state: British Columbia, latitude: 49.2448, longitude: -123.1154, time: 16:58, time_zone: -8, obs_daylight: 0, current_gmt_offset: -8, time_zone_abbreviation: PST"
97
99
  ```
98
100
 
101
+ Get local times for the rise and set of celestial bodies in our solar system:
102
+
103
+ ```ruby
104
+ planets = Accuweather.get_conditions(location_id: 'cityId:53286').planets
105
+ planets.sunrise # => "8:00 AM"
106
+ planets.moonrise # => "12/14/2015 10:14:00 AM"
107
+ planets.sunset # => "4:14 PM"
108
+ planets.marsrise # => "10:16 AM"
109
+ planets.plutoset # => "2:04 AM"
110
+ ```
111
+
99
112
  ## Development
100
113
 
101
114
  Run `rake` to run the tests
@@ -5,6 +5,7 @@ require 'accuweather/location/parser'
5
5
  require 'accuweather/conditions/parser'
6
6
  require 'accuweather/conditions/units'
7
7
  require 'accuweather/conditions/local'
8
+ require 'accuweather/conditions/planets'
8
9
  require 'accuweather/conditions/current'
9
10
  require 'accuweather/conditions/forecast_day'
10
11
  require 'accuweather/conditions/forecast_weather'
@@ -28,6 +28,32 @@ module Accuweather
28
28
  )
29
29
  end
30
30
 
31
+ def planets
32
+ planets = @doc.css('planets').first
33
+
34
+ Accuweather::Conditions::Planets.new(
35
+ sunrise: planets.css('sun').first['rise'],
36
+ sunset: planets.css('sun').first['set'],
37
+ moonrise: planets.css('moon').first['rise'],
38
+ moonset: planets.css('moon').first['set'],
39
+ mercuryrise: planets.css('mercury').first['rise'],
40
+ mercuryset: planets.css('mercury').first['set'],
41
+ venusrise: planets.css('venus').first['rise'],
42
+ venusset: planets.css('venus').first['set'],
43
+ marsrise: planets.css('mars').first['rise'],
44
+ marsset: planets.css('mars').first['set'],
45
+ jupiterrise: planets.css('jupiter').first['rise'],
46
+ jupiterset: planets.css('jupiter').first['set'],
47
+ saturnrise: planets.css('saturn').first['rise'],
48
+ saturnset: planets.css('saturn').first['set'],
49
+ uranusrise: planets.css('uranus').first['rise'],
50
+ uranusset: planets.css('uranus').first['set'],
51
+ neptunerise: planets.css('neptune').first['rise'],
52
+ neptuneset: planets.css('neptune').first['set'],
53
+ plutorise: planets.css('pluto').first['rise'],
54
+ plutoset: planets.css('pluto').first['set'])
55
+ end
56
+
31
57
  def current
32
58
  current = @doc.css('currentconditions').first
33
59
  Accuweather::Conditions::Current.new(observation_time: current.css('observationtime').text,
@@ -0,0 +1,59 @@
1
+ module Accuweather
2
+ module Conditions
3
+ class Planets
4
+ attr_reader :sunrise, :sunset, :moonrise, :moonset, :mercuryrise, :mercuryset, :venusrise, :venusset, :marsrise, :marsset, :jupiterrise, :jupiterset, :saturnrise, :saturnset, :uranusrise, :uranusset, :neptunerise, :neptuneset, :plutorise, :plutoset
5
+
6
+ def initialize(sunrise:, sunset:, moonrise:, moonset:, mercuryrise:, mercuryset:, venusrise:, venusset:, marsrise:, marsset:, jupiterrise:, jupiterset:, saturnrise:, saturnset:, uranusrise:, uranusset:, neptunerise:, neptuneset:, plutorise:, plutoset:)
7
+ @sunrise = sunrise
8
+ @sunset = sunset
9
+ @moonrise = moonrise
10
+ @moonset = moonset
11
+ @mercuryrise = mercuryrise
12
+ @mercuryset = mercuryset
13
+ @venusrise = venusrise
14
+ @venusset = venusset
15
+ @marsrise = marsrise
16
+ @marsset = marsset
17
+ @jupiterrise = jupiterrise
18
+ @jupiterset = jupiterset
19
+ @saturnrise = saturnrise
20
+ @saturnset = saturnset
21
+ @uranusrise = uranusrise
22
+ @uranusset = uranusset
23
+ @neptunerise = neptunerise
24
+ @neptuneset = neptuneset
25
+ @plutorise = plutorise
26
+ @plutoset = plutoset
27
+ end
28
+
29
+ def ==(other)
30
+ sunrise == other.sunrise &&
31
+ sunset == other.sunset &&
32
+ moonrise == other.moonrise &&
33
+ moonset == other.moonset &&
34
+ mercuryrise == other.mercuryrise &&
35
+ mercuryset == other.mercuryset &&
36
+ venusrise == other.venusrise &&
37
+ venusset == other.venusset &&
38
+ marsrise == other.marsrise &&
39
+ marsset == other.marsset &&
40
+ jupiterrise == other.jupiterrise &&
41
+ jupiterset == other.jupiterset &&
42
+ saturnrise == other.saturnrise &&
43
+ saturnset == other.saturnset &&
44
+ uranusrise == other.uranusrise &&
45
+ uranusset == other.uranusset &&
46
+ neptunerise == other.neptunerise &&
47
+ neptuneset == other.neptuneset &&
48
+ plutorise == other.plutorise &&
49
+ plutoset == other.plutoset
50
+ rescue NoMethodError
51
+ false
52
+ end
53
+
54
+ def to_s
55
+ "sunrise: #{sunrise}, sunset: #{sunset}, moonrise: #{moonrise}, moonset: #{moonset}, mercuryrise: #{mercuryrise}, mercuryset: #{mercuryset}, venusrise: #{venusrise}, venusset: #{venusset}, marsrise: #{marsrise}, marsset: #{marsset}, jupiterrise: #{jupiterrise}, jupiterset: #{jupiterset}, saturnrise: #{saturnrise}, saturnset: #{saturnset}, uranusrise: #{uranusrise}, uranusset: #{uranusset}, neptunerise: #{neptunerise}, neptuneset: #{neptuneset}, plutorise: #{plutorise}, plutoset: #{plutoset}"
56
+ end
57
+ end
58
+ end
59
+ end
@@ -1,3 +1,3 @@
1
1
  module Accuweather
2
- VERSION = '0.2.2'
2
+ VERSION = '0.2.3'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: accuweather
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nick Aschenbach
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-12-05 00:00:00.000000000 Z
11
+ date: 2015-12-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -94,6 +94,7 @@ files:
94
94
  - lib/accuweather/conditions/forecast_weather.rb
95
95
  - lib/accuweather/conditions/local.rb
96
96
  - lib/accuweather/conditions/parser.rb
97
+ - lib/accuweather/conditions/planets.rb
97
98
  - lib/accuweather/conditions/units.rb
98
99
  - lib/accuweather/location/cache.rb
99
100
  - lib/accuweather/location/city.rb