Notams
A ruby gem for retrieving the currently active NOTAMs for an airport or a region.
Supports multiple airports/regions in one request. Pulls data from
FAA website. Depends on nokogiri
for the heavy lifting.
Requirements
Ruby 1.9.3 or higher | Supports Ruby 2.0!
Installation
Add this line to your application's Gemfile:
gem 'notams'
And then execute:
$ bundle
Or install it yourself as:
$ gem install notams
Usage
Easy mode
The .notams
method can be applied to any string literal or variable,
representing a valid ICAO code of an airport or FIR, or a comma-separated list
of airports/regions. It will return an array, containing all the currently
active NOTAMs for your selection. You can loop through the array to display or
parse individual notams. I figured this would be the most common use case. For
advanced usage and possible customizations see below.
icao = "lowi"
icao.notams
"lowi".notams
icao = "lqsa,lqsb"
icao.notams
Advanced usage
The .notams
method can be customized by passing an optional hash of arguments.
The :objects => true
option will cause the .notams
method to return an array
of notam objects instead of strings. Thus each notam is parsed and
encapuslated in an instance of the Notam
class and exposes a number of
attributes:
icao = "lqsa"
icao.notams(:objects => true)
notam = icao.notams.first
notam.raw
notam.icao
notam.message
Example Ruby on Rails implementation
Here's a possible scenario of using this gem in a Ruby on Rails application.
Verbosity is kept on purpose for clarity.
In your controller:
def action
icao = "lqsa, lqsb"
@notams = icao.notams(:objects => true)
end
In your view (HAML is used for clarity):
// We could play with the attributes individually if we need to:
- for notam in @notams
%li
= notam.icao
= notam.message
// Or we could just loop through the raw notams:
- for notam in @notams
%li= notam.raw
Changelog
v. 0.2.0 27 February 2013
- Ruby 2.0 support
- dependencies update
- classes refactored
v. 0.1.0 28 July 2012
- added optional arguments customization to the
.notams
method (see Advanced Usage) - code refactored into classes for flexibility
Contributing
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Added some feature'
) - Make sure all tests pass!
- Push to the branch (
git push origin my-new-feature
) - Create new Pull Request
Credits
Copyright © 2013 Svilen Vassilev
If you find my work useful or time-saving, you can endorse it or buy me a cup of coffee:
Released under the MIT LICENSE