Module: Accuweather
- Defined in:
- lib/accuweather.rb,
lib/accuweather/version.rb,
lib/accuweather/location.rb,
lib/accuweather/conditions/local.rb,
lib/accuweather/conditions/units.rb,
lib/accuweather/conditions/parser.rb,
lib/accuweather/conditions/current.rb
Defined Under Namespace
Modules: Conditions
Classes: Location
Constant Summary
collapse
- VERSION =
'0.1.1'
Class Method Summary
collapse
Class Method Details
.city_search(name) ⇒ Object
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
# File 'lib/accuweather.rb', line 12
def self.city_search(name)
response = Net::HTTP.get('samsungmobile.accu-weather.com',
"/widget/samsungmobile/city-find.asp?returnGeoPosition=1&location=#{name}")
xml = Nokogiri::XML.parse(response)
xml.css('location').map do |location|
Accuweather::Location.new(id: location.attr('location'),
city: location.attr('city'),
state: location.attr('state'),
latitude: location.attr('latitude'),
longitude: location.attr('longitude'))
end
rescue StandardError
[]
end
|
.get_conditions(location_id) ⇒ Object
29
30
31
32
33
34
35
36
|
# File 'lib/accuweather.rb', line 29
def self.get_conditions(location_id)
response = Net::HTTP.get('samsungmobile.accu-weather.com',
"/widget/samsungmobile/weather-data.asp?metric=0&location=#{location_id}")
Accuweather::Conditions::Parser.new(response)
rescue StandardError
nil
end
|