owmo 0.2.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +0 -1
- data/README.md +66 -30
- data/examples/current.rb +13 -0
- data/examples/forecast16.rb +14 -0
- data/examples/forecast5.rb +14 -0
- data/examples/query_all.rb +16 -0
- data/examples/query_geocode.rb +20 -0
- data/examples/query_mode.rb +15 -0
- data/examples/query_units.rb +14 -0
- data/lib/owmo/version.rb +1 -1
- data/lib/owmo/weather.rb +53 -19
- data/lib/owmo.rb +3 -49
- data/owmo.gemspec +0 -9
- metadata +9 -5
- data/examples/current_conditions.rb +0 -21
- data/examples/extended.rb +0 -22
- data/examples/forecast.rb +0 -22
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 76cf3aad7eed6385b91969ab9e129367ce8e7b40
|
4
|
+
data.tar.gz: 4604435004a67f5e01bba1c0c789b1823351bafc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6a5c8504dde37e3b907e57cfa71cec9f3e8a9c1008ba38421d90be8b4131d67de3bf478af4f79650a3d69d18079ae3355e584a584b7973892cfad72ed1980e17
|
7
|
+
data.tar.gz: 67ab4aa60a944b7141ba01e85b47454600c72042ac4fa4536501182fd252c36eaebeabe6b24298c46746b3793ce7c967f84a1047fd709b50d8a80c295045f599
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -32,55 +32,91 @@ Compelete examples can be found under owmo/examples.
|
|
32
32
|
```ruby
|
33
33
|
require 'owmo'
|
34
34
|
api_key = "<api key here>"
|
35
|
-
weather = OWMO::Weather.new api_key
|
36
|
-
puts weather.get :current,
|
35
|
+
weather = OWMO::Weather.new api_key
|
36
|
+
puts weather.get :current, city_name: "London,UK"
|
37
37
|
```
|
38
38
|
|
39
39
|
```ruby
|
40
40
|
require 'owmo'
|
41
41
|
api_key = "<api key here>"
|
42
|
-
OWMO::weather api_key
|
43
|
-
puts weather.get :forecast,
|
42
|
+
OWMO::weather api_key do |weather|
|
43
|
+
puts weather.get :forecast, city_name: "London,UK"
|
44
44
|
end
|
45
45
|
```
|
46
46
|
----
|
47
|
+
### Weather Information
|
48
|
+
#### Current weather data (http://openweathermap.org/current)
|
49
|
+
```ruby
|
50
|
+
puts weather.get :current, city_name: "London,UK"
|
51
|
+
```
|
52
|
+
#### 5 day weather forecast (http://openweathermap.org/forecast5)
|
53
|
+
```ruby
|
54
|
+
puts weather.get :forecast5, city_name: "London,UK"
|
55
|
+
```
|
56
|
+
#### 16 day weather forecast (http://openweathermap.org/forecast16)
|
57
|
+
```ruby
|
58
|
+
puts weather.get :forecast16, city_name: "London,UK"
|
59
|
+
```
|
60
|
+
|
61
|
+
----
|
62
|
+
### Query parameters
|
63
|
+
|
64
|
+
#### Geocode (required)
|
65
|
+
```ruby
|
66
|
+
# Geocode by City ID
|
67
|
+
puts weather.get :current, city_id: 5328041
|
68
|
+
puts weather.get :current, id: 5328041
|
69
|
+
|
70
|
+
# Geocode by City Name
|
71
|
+
puts weather.get :current, city_name: "Beverly Hills"
|
72
|
+
puts weather.get :current, q: "Beverly Hills"
|
73
|
+
|
74
|
+
# Geocode by Zip Code
|
75
|
+
puts weather.get :current, zip: 90210
|
76
|
+
puts weather.get :current, zip_code: 90210
|
77
|
+
|
78
|
+
# Geocode by Coordinance
|
79
|
+
puts weather.get :current, lon: -118.41, lat: 34.09
|
80
|
+
```
|
47
81
|
|
48
|
-
|
82
|
+
#### Mode
|
49
83
|
```ruby
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
units: 'imperial', # [imperial, metric] Not required, but an option
|
54
|
-
lang: 'en_US' # Not required, but an option
|
55
|
-
}
|
84
|
+
# Response in JSON format (default)
|
85
|
+
puts weather.get :current, city_name: "London,UK"
|
86
|
+
puts weather.get :current, city_name: "London,UK", mode: :json
|
56
87
|
|
57
|
-
|
88
|
+
# Response in XML format
|
89
|
+
puts weather.get :current, city_name: "London,UK", mode: :xml
|
58
90
|
|
91
|
+
# Response in HTML format
|
92
|
+
puts weather.get :current, city_name: "London,UK", mode: :html
|
59
93
|
```
|
60
|
-
|
94
|
+
|
95
|
+
#### Units
|
61
96
|
```ruby
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
97
|
+
# Kelvin (default)
|
98
|
+
puts weather.get :current, city_name: "London,UK"
|
99
|
+
|
100
|
+
# Imperial
|
101
|
+
puts weather.get :current, city_name: "London,UK", units: :imperial
|
102
|
+
|
103
|
+
# Metric
|
104
|
+
puts weather.get :current, city_name: "London,UK", units: :metric
|
70
105
|
```
|
71
106
|
|
72
|
-
|
107
|
+
#### All
|
73
108
|
```ruby
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
109
|
+
query = {
|
110
|
+
city_name: "London,UK",
|
111
|
+
mode: 'json',
|
112
|
+
units: 'imperial',
|
113
|
+
lang: 'fr'
|
114
|
+
}
|
115
|
+
|
116
|
+
puts weather.get :current, query
|
82
117
|
```
|
83
118
|
|
119
|
+
----
|
84
120
|
## Development
|
85
121
|
|
86
122
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
data/examples/current.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'owmo'
|
2
|
+
|
3
|
+
=begin rdoc
|
4
|
+
An example on how to get current conditions and use the different parameters.
|
5
|
+
=end
|
6
|
+
api_key = ""
|
7
|
+
|
8
|
+
weather = OWMO::Weather.new api_key
|
9
|
+
|
10
|
+
# http://openweathermap.org/current#data
|
11
|
+
current = weather.get :current, city_name: "London,UK"
|
12
|
+
|
13
|
+
puts current
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'owmo'
|
2
|
+
|
3
|
+
|
4
|
+
=begin rdoc
|
5
|
+
An example on how to get the weather forcast and use the different parameters.
|
6
|
+
=end
|
7
|
+
api_key = ""
|
8
|
+
|
9
|
+
weather = OWMO::Weather.new api_key
|
10
|
+
|
11
|
+
# http://openweathermap.org/forecast16
|
12
|
+
forecast16 = weather.get :forecast16, city_name: "London,UK"
|
13
|
+
|
14
|
+
puts forecast16
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'owmo'
|
2
|
+
|
3
|
+
|
4
|
+
=begin rdoc
|
5
|
+
An example on how to get the extended forcast and use the different parameters.
|
6
|
+
=end
|
7
|
+
api_key = ""
|
8
|
+
|
9
|
+
weather = OWMO::Weather.new api_key
|
10
|
+
|
11
|
+
# http://openweathermap.org/forecast5
|
12
|
+
forecast5 = weather.get :forecast5, city_name: "London,UK"
|
13
|
+
|
14
|
+
puts forecast5
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'owmo'
|
2
|
+
|
3
|
+
api_key = ""
|
4
|
+
|
5
|
+
weather = OWMO::Weather.new api_key
|
6
|
+
|
7
|
+
query = {
|
8
|
+
city_name: "London,UK", # Geolocation, required
|
9
|
+
mode: 'json', # Return data [json (defaul), xml, html]
|
10
|
+
units: 'imperial', # [imperial, metric, or blank (Default, Kelvin)]
|
11
|
+
lang: 'fr' # Language support
|
12
|
+
}
|
13
|
+
|
14
|
+
current = weather.get :current, query
|
15
|
+
|
16
|
+
puts current
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'owmo'
|
2
|
+
|
3
|
+
api_key = ""
|
4
|
+
|
5
|
+
weather = OWMO::Weather.new api_key
|
6
|
+
|
7
|
+
# Geocode by City ID
|
8
|
+
puts weather.get :current, city_id: 5328041
|
9
|
+
puts weather.get :current, id: 5328041
|
10
|
+
|
11
|
+
# Geocode by City Name
|
12
|
+
puts weather.get :current, city_name: "Beverly Hills"
|
13
|
+
puts weather.get :current, q: "Beverly Hills"
|
14
|
+
|
15
|
+
# Geocode by Zip Code
|
16
|
+
puts weather.get :current, zip: 90210
|
17
|
+
puts weather.get :current, zip_code: 90210
|
18
|
+
|
19
|
+
# Geocode by Coordinance
|
20
|
+
puts weather.get :current, lon: -118.41, lat: 34.09
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'owmo'
|
2
|
+
|
3
|
+
api_key = ""
|
4
|
+
|
5
|
+
weather = OWMO::Weather.new api_key
|
6
|
+
|
7
|
+
# Response in JSON format
|
8
|
+
puts weather.get :current, city_name: "London,UK"
|
9
|
+
puts weather.get :current, city_name: "London,UK", mode: :json
|
10
|
+
|
11
|
+
# Response in XML format
|
12
|
+
puts weather.get :current, city_name: "London,UK", mode: :xml
|
13
|
+
|
14
|
+
# Response in HTML format
|
15
|
+
puts weather.get :current, city_name: "London,UK", mode: :html
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'owmo'
|
2
|
+
|
3
|
+
api_key = ""
|
4
|
+
|
5
|
+
weather = OWMO::Weather.new api_key
|
6
|
+
|
7
|
+
# Kelvin
|
8
|
+
puts weather.get :current, city_name: "London,UK"
|
9
|
+
|
10
|
+
# Imperial
|
11
|
+
puts weather.get :current, city_name: "London,UK", units: :imperial
|
12
|
+
|
13
|
+
# Metric
|
14
|
+
puts weather.get :current, city_name: "London,UK", units: :metric
|
data/lib/owmo/version.rb
CHANGED
data/lib/owmo/weather.rb
CHANGED
@@ -16,14 +16,53 @@ A weather class for retrieving current and forecasted weather conditions.
|
|
16
16
|
=end
|
17
17
|
class Weather
|
18
18
|
|
19
|
+
attr_reader :api_key, :Paths, :Geocodes
|
20
|
+
|
19
21
|
=begin rdoc
|
20
|
-
|
22
|
+
Access current or forecasted conditions by (required):
|
23
|
+
* +:current+ - {Current weather data}[http://openweathermap.org/current]
|
24
|
+
* +:forecast5+ - {5 day / 3 hour forecast}[http://openweathermap.org/forecast5]
|
25
|
+
* +:forecast16+ - {16 day / daily forecast}[http://openweathermap.org/forecast16]
|
21
26
|
=end
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
+
Paths = {
|
28
|
+
current: 'weather', # Current weather data
|
29
|
+
forecast5: 'forecast', # 5 day / 3 hour forecast
|
30
|
+
forecast16: 'forecast/daily' # 16 day / daily forecast
|
31
|
+
}
|
32
|
+
|
33
|
+
=begin rdoc
|
34
|
+
{Geocode options (required):}[http://openweathermap.org/current#one]
|
35
|
+
* +q:+ or +city_name:+ - By city name
|
36
|
+
* +id:+ or +city_id:+ - By city ID
|
37
|
+
* +zip:+ or +zip_code:+ - By zip code
|
38
|
+
* +lat:+, +lon:+ or +latitude:+, +longitude:+ - By geographic coordinates
|
39
|
+
=end
|
40
|
+
Geocodes = {
|
41
|
+
"City Name" => {
|
42
|
+
query: :q,
|
43
|
+
options: [:q, :city_name]
|
44
|
+
},
|
45
|
+
"City ID" => {
|
46
|
+
query: :id,
|
47
|
+
options: [:id, :city_id]
|
48
|
+
},
|
49
|
+
"Zip Code" => {
|
50
|
+
query: :zip,
|
51
|
+
options: [:zip, :zip_code]
|
52
|
+
},
|
53
|
+
"Coordinance" => {
|
54
|
+
query: [:lat, :lon],
|
55
|
+
options: [[:lat, :lon], [:lattitude, :longitude]]
|
56
|
+
},
|
57
|
+
"Cities Within a Rectangle Zone" => {
|
58
|
+
query: :bbox,
|
59
|
+
options: [:bbox]
|
60
|
+
},
|
61
|
+
"Cities Within a Circle" => {
|
62
|
+
query: [:lat, :lon, :cnt],
|
63
|
+
options: [[:lat, :lon, :cnt],[:lattitude, :longitude, :cnt]]
|
64
|
+
}
|
65
|
+
}
|
27
66
|
|
28
67
|
=begin rdoc
|
29
68
|
Invalid path specified
|
@@ -31,7 +70,7 @@ Invalid path specified
|
|
31
70
|
class InvalidPathSpecified < StandardError
|
32
71
|
def initialize(path=nil)
|
33
72
|
@path = path
|
34
|
-
super("Invalid path specified: Got: '#{@path}', expected one of: #{
|
73
|
+
super("Invalid path specified: Got: '#{@path}', expected one of: #{Paths.keys}")
|
35
74
|
end # initialize
|
36
75
|
end # NoGeocodeSpecified
|
37
76
|
|
@@ -41,20 +80,15 @@ Missing Geocode from query
|
|
41
80
|
class MissingGeocodes < StandardError
|
42
81
|
end # MissingGeocodes
|
43
82
|
|
44
|
-
=begin rdoc
|
45
|
-
{OpenWeatherMap.org API key}[http://openweathermap.org/appid]
|
46
|
-
=end
|
47
|
-
attr_reader :api_key
|
48
83
|
|
49
|
-
def initialize(**kwargs) #:notnew:
|
50
|
-
|
51
|
-
@api_key = kwargs[:api_key]
|
84
|
+
def initialize(api_key, **kwargs) #:notnew:
|
85
|
+
@api_key = api_key
|
52
86
|
end # initialize
|
53
87
|
|
54
88
|
=begin rdoc
|
55
89
|
A weather class for retrieving current and forecasted weather conditions.
|
56
90
|
==== Attributes
|
57
|
-
* +path+ - OWMO::
|
91
|
+
* +path+ - OWMO::Wether.Path parameter
|
58
92
|
* +query+ - Hash of query options (Geocode, response format, units, etc.)
|
59
93
|
==== Examples
|
60
94
|
api_key = "<My API Key>"
|
@@ -67,11 +101,11 @@ A weather class for retrieving current and forecasted weather conditions.
|
|
67
101
|
query = check_geocodes query
|
68
102
|
|
69
103
|
# Add the api key
|
70
|
-
query[:APPID] = @api_key
|
104
|
+
query[:APPID] = @api_key
|
71
105
|
|
72
106
|
# Create the uri
|
73
|
-
raise InvalidPathSpecified.new(path) if
|
74
|
-
uri = URI "#{OWMO::URL}/#{
|
107
|
+
raise InvalidPathSpecified.new(path) if Paths[path].nil?
|
108
|
+
uri = URI "#{OWMO::URL}/#{Paths[path]}?#{URI.encode_www_form(query)}"
|
75
109
|
|
76
110
|
# Get the weather data
|
77
111
|
OWMO::API.get(uri)
|
@@ -86,7 +120,7 @@ Ensure appropriate query options are applied to the final URI
|
|
86
120
|
# May never be called since query is required
|
87
121
|
raise MissingGeocodes if query.size == 0
|
88
122
|
|
89
|
-
|
123
|
+
Geocodes.each do |name, geocodes|
|
90
124
|
|
91
125
|
# Get the common keys
|
92
126
|
intersect = geocodes[:options].flatten & query.keys
|
data/lib/owmo.rb
CHANGED
@@ -13,52 +13,6 @@ Openweathermap.org URL
|
|
13
13
|
=end
|
14
14
|
URL = 'http://api.openweathermap.org/data/2.5'
|
15
15
|
|
16
|
-
=begin rdoc
|
17
|
-
Access current or forecasted conditions by (required):
|
18
|
-
* +:current+ - {Current weather data}[http://openweathermap.org/current]
|
19
|
-
* +:forecast+ - {5 day / 3 hour forecast}[http://openweathermap.org/forecast5]
|
20
|
-
* +:extended+ - {16 day / daily forecast}[http://openweathermap.org/forecast16]
|
21
|
-
=end
|
22
|
-
PATHS = {
|
23
|
-
current: 'weather', # Current weather data
|
24
|
-
forecast: 'forecast', # 5 day / 3 hour forecast
|
25
|
-
extended: 'forecast/daily' # 16 day / daily forecast
|
26
|
-
}
|
27
|
-
|
28
|
-
=begin rdoc
|
29
|
-
{Geocode options (required):}[http://openweathermap.org/current#one]
|
30
|
-
* +q:+ or +city_name:+ - By city name
|
31
|
-
* +id:+ or +city_id:+ - By city ID
|
32
|
-
* +zip:+ or +zip_code:+ - By zip code
|
33
|
-
* +lat:+, +lon:+ or +latitude:+, +longitude:+ - By geographic coordinates
|
34
|
-
=end
|
35
|
-
GEOCODES = {
|
36
|
-
"City Name" => {
|
37
|
-
query: :q,
|
38
|
-
options: [:q, :city_name]
|
39
|
-
},
|
40
|
-
"City ID" => {
|
41
|
-
query: :id,
|
42
|
-
options: [:id, :city_id]
|
43
|
-
},
|
44
|
-
"Zip Code" => {
|
45
|
-
query: :zip,
|
46
|
-
options: [:zip, :zip_code]
|
47
|
-
},
|
48
|
-
"Coordinance" => {
|
49
|
-
query: [:lat, :lon],
|
50
|
-
options: [[:lat, :lon], [:lattitude, :longitude]]
|
51
|
-
},
|
52
|
-
"Cities Within a Rectangle Zone" => {
|
53
|
-
query: :bbox,
|
54
|
-
options: [:bbox]
|
55
|
-
},
|
56
|
-
"Cities Within a Circle" => {
|
57
|
-
query: [:lat, :lon, :cnt],
|
58
|
-
options: [[:lat, :lon, :cnt],[:lattitude, :longitude, :cnt]]
|
59
|
-
}
|
60
|
-
}
|
61
|
-
|
62
16
|
=begin rdoc
|
63
17
|
Yield a weather object for querying weather data
|
64
18
|
==== Attributes
|
@@ -70,9 +24,9 @@ Yield a weather object for querying weather data
|
|
70
24
|
end
|
71
25
|
=end
|
72
26
|
public
|
73
|
-
def self.weather(**params)
|
74
|
-
|
75
|
-
yield
|
27
|
+
def self.weather(api_key, **params)
|
28
|
+
weather = Weather.new api_key, params
|
29
|
+
yield weather
|
76
30
|
end # weather
|
77
31
|
|
78
32
|
end # OWMO
|
data/owmo.gemspec
CHANGED
@@ -14,15 +14,6 @@ Gem::Specification.new do |spec|
|
|
14
14
|
spec.homepage = "https://github.com/robb-randall/owmo"
|
15
15
|
spec.license = "MIT"
|
16
16
|
|
17
|
-
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
18
|
-
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
19
|
-
# if spec.respond_to?(:metadata)
|
20
|
-
# spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com'"
|
21
|
-
# else
|
22
|
-
# raise "RubyGems 2.0 or newer is required to protect against " \
|
23
|
-
# "public gem pushes."
|
24
|
-
# end
|
25
|
-
|
26
17
|
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
27
18
|
f.match(%r{^(test|spec|features)/})
|
28
19
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: owmo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Robb
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-06-
|
11
|
+
date: 2017-06-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -69,9 +69,13 @@ files:
|
|
69
69
|
- _config.yml
|
70
70
|
- bin/console
|
71
71
|
- bin/setup
|
72
|
-
- examples/
|
73
|
-
- examples/
|
74
|
-
- examples/
|
72
|
+
- examples/current.rb
|
73
|
+
- examples/forecast16.rb
|
74
|
+
- examples/forecast5.rb
|
75
|
+
- examples/query_all.rb
|
76
|
+
- examples/query_geocode.rb
|
77
|
+
- examples/query_mode.rb
|
78
|
+
- examples/query_units.rb
|
75
79
|
- lib/core_extensions/core_extensions.rb
|
76
80
|
- lib/core_extensions/net/http_response/weather_response.rb
|
77
81
|
- lib/owmo.rb
|
@@ -1,21 +0,0 @@
|
|
1
|
-
require 'owmo'
|
2
|
-
|
3
|
-
=begin rdoc
|
4
|
-
An example on how to get current conditions and use the different parameters.
|
5
|
-
=end
|
6
|
-
api_key = ""
|
7
|
-
|
8
|
-
OWMO::weather api_key: api_key do |weather|
|
9
|
-
|
10
|
-
# http://openweathermap.org/current#data
|
11
|
-
query = {
|
12
|
-
city_name: "London,uk", # [city_name, city_id, zip, lat/lon]
|
13
|
-
mode: 'json', # [json, xml, html] Not required, but an option
|
14
|
-
units: 'imperial', # [imperial, metric] Not required, but an option
|
15
|
-
lang: 'en_US' # Not required, but an option
|
16
|
-
}
|
17
|
-
|
18
|
-
current_condition = weather.get :current, query
|
19
|
-
|
20
|
-
puts current_condition
|
21
|
-
end
|
data/examples/extended.rb
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
require 'owmo'
|
2
|
-
|
3
|
-
|
4
|
-
=begin rdoc
|
5
|
-
An example on how to get the weather forcast and use the different parameters.
|
6
|
-
=end
|
7
|
-
api_key = ""
|
8
|
-
|
9
|
-
OWMO::weather api_key: api_key do |weather|
|
10
|
-
|
11
|
-
# http://openweathermap.org/forecast16
|
12
|
-
query = {
|
13
|
-
lat: "40.7128", lon: "74.0059", # [city_name, city_id, zip, lat/lon]
|
14
|
-
mode: 'json', # [json, xml, html] Not required, but an option
|
15
|
-
units: 'imperial', # [imperial, metric] Not required, but an option
|
16
|
-
lang: 'en_US' # Not required, but an option
|
17
|
-
}
|
18
|
-
|
19
|
-
extended = weather.get :extended, query
|
20
|
-
|
21
|
-
puts extended
|
22
|
-
end
|
data/examples/forecast.rb
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
require 'owmo'
|
2
|
-
|
3
|
-
|
4
|
-
=begin rdoc
|
5
|
-
An example on how to get the extended forcast and use the different parameters.
|
6
|
-
=end
|
7
|
-
api_key = ""
|
8
|
-
|
9
|
-
OWMO::weather api_key: api_key do |weather|
|
10
|
-
|
11
|
-
# http://openweathermap.org/forecast5
|
12
|
-
query = {
|
13
|
-
zip: "90210", # [city_name, city_id, zip, lat/lon]
|
14
|
-
mode: 'json', # [json, xml, html] Not required, but an option
|
15
|
-
units: 'imperial', # [imperial, metric] Not required, but an option
|
16
|
-
lang: 'en_US' # Not required, but an option
|
17
|
-
}
|
18
|
-
|
19
|
-
forecast = weather.get :forecast, query
|
20
|
-
|
21
|
-
puts forecast
|
22
|
-
end
|