Class: Metar_record

Inherits:
Object
  • Object
show all
Defined in:
lib/metar_record.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#stationObject

Returns the value of attribute station.



6
7
8
# File 'lib/metar_record.rb', line 6

def station
  @station
end

#urlObject

Returns the value of attribute url.



6
7
8
# File 'lib/metar_record.rb', line 6

def url
  @url
end

Instance Method Details

#adds_urlObject



13
14
15
# File 'lib/metar_record.rb', line 13

def adds_url
  return "#{url}#{station.upcase}"
end

#get_metarObject



21
22
23
24
25
26
27
28
# File 'lib/metar_record.rb', line 21

def get_metar
  begin
    doc = Nokogiri::HTML(open(adds_url))
    return doc.xpath('//font').first.text
  rescue
    return nil
  end
end

#get_xmlObject



17
18
19
# File 'lib/metar_record.rb', line 17

def get_xml
  xml = Nokogiri::HTML(open(self.adds_url))
end