Skip to content

Commit e113073

Browse files
authored
Merge pull request #34 from Phitherek/city_search
Add poorly documented find endpoint with like and accurate options
2 parents df7014a + d6b0932 commit e113073

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

lib/open_weather.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ module OpenWeather
55
autoload :Current, 'open_weather/current'
66
autoload :Forecast, 'open_weather/forecast'
77
autoload :ForecastDaily, 'open_weather/forecast_daily'
8+
autoload :Find, 'open_weather/find'
89
autoload :VERSION, 'open_weather/version'
910

1011
require 'open_weather/api.rb'

lib/open_weather/base.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def success?
2525

2626
def extract_options!(options)
2727
valid_options = [ :id, :lat, :lon, :cnt, :city, :lang, :units, :APPID,
28-
:country, :bbox]
28+
:country, :bbox, :q, :type]
2929

3030
options.keys.each { |k| options.delete(k) unless valid_options.include?(k) }
3131

lib/open_weather/find.rb

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
module OpenWeather
2+
class Find < Base
3+
def initialize(options = {})
4+
super('http://api.openweathermap.org/data/2.5/find', options)
5+
end
6+
7+
def self.like(q, options = {})
8+
new(options.merge!(q: q, type: 'like')).retrieve
9+
end
10+
11+
def self.accurate(q, options = {})
12+
new(options.merge!(q: q, type: 'accurate')).retrieve
13+
end
14+
end
15+
end

0 commit comments

Comments
 (0)