Class: Barometer::Query::Service::NoaaStation
- Inherits:
-
Object
- Object
- Barometer::Query::Service::NoaaStation
- Defined in:
- lib/barometer/query/services/noaa_station_id.rb,
lib/barometer/query/services/apis/noaa_station.rb
Defined Under Namespace
Classes: Api
Class Method Summary collapse
Class Method Details
._parse_content(content) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/barometer/query/services/noaa_station_id.rb', line 16 def self._parse_content(content) doc = Nokogiri::HTML.parse(content) if doc extra_links = doc.search(".current-conditions-extra a") if sid_link = extra_links.detect{|link| link.attr('href').match(/sid=(.*)&/)} sid_link.attr('href').match(/sid=(.*?)&/)[1] elsif three_day_link = extra_links.detect{|link| link.text.match(/3 Day History/)} three_day_link.attr('href').match(/\/([A-Za-z]*?)\.html/)[1] end end rescue nil end |
.fetch(query) ⇒ Object
8 9 10 11 12 13 14 |
# File 'lib/barometer/query/services/noaa_station_id.rb', line 8 def self.fetch(query) converted_query = query.get_conversion(:coordinates) return unless converted_query api = NoaaStation::Api.new(converted_query) _parse_content(api.get) end |