Class: Metar_record
- Inherits:
-
Object
- Object
- Metar_record
- Defined in:
- lib/metar_record.rb
Instance Attribute Summary collapse
-
#station ⇒ Object
Returns the value of attribute station.
-
#url ⇒ Object
Returns the value of attribute url.
Instance Method Summary collapse
- #adds_url ⇒ Object
- #get_metar ⇒ Object
- #get_xml ⇒ Object
-
#initialize(stn) ⇒ Metar_record
constructor
A new instance of Metar_record.
Constructor Details
#initialize(stn) ⇒ Metar_record
Returns a new instance of Metar_record.
8 9 10 11 |
# File 'lib/metar_record.rb', line 8 def initialize(stn) self.station = stn self.url = "http://aviationweather.gov/adds/metars/index.php?station_ids=" end |
Instance Attribute Details
#station ⇒ Object
Returns the value of attribute station.
6 7 8 |
# File 'lib/metar_record.rb', line 6 def station @station end |
#url ⇒ Object
Returns the value of attribute url.
6 7 8 |
# File 'lib/metar_record.rb', line 6 def url @url end |
Instance Method Details
#adds_url ⇒ Object
13 14 15 |
# File 'lib/metar_record.rb', line 13 def adds_url return "#{url}#{station.upcase}" end |
#get_metar ⇒ Object
21 22 23 24 25 26 27 28 |
# File 'lib/metar_record.rb', line 21 def begin doc = Nokogiri::HTML(open(adds_url)) return doc.xpath('//font').first.text rescue return nil end end |
#get_xml ⇒ Object
17 18 19 |
# File 'lib/metar_record.rb', line 17 def get_xml xml = Nokogiri::HTML(open(self.adds_url)) end |