Skip to content

Commit

Permalink
readme
Browse files Browse the repository at this point in the history
  • Loading branch information
tarakanbg committed Jun 29, 2012
1 parent 88319fa commit 586da1f
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 17 deletions.
23 changes: 21 additions & 2 deletions README.md
@@ -1,6 +1,6 @@
# VatsimMetar

TODO: Write a gem description
A Ruby gem which pulls and displays the latest VATSIM metar for a particular station (ICAO code).

## Installation

Expand All @@ -18,7 +18,26 @@ Or install it yourself as:

## Usage

TODO: Write usage instructions here
The `.metar` method can be applied to a string (or variable containing a string), representing a valid ICAO code. Like this:

```ruby
"EGLL".metar # => "EGLL 291750Z 22016KT 9999 SCT023 SCT032 18/13 Q1005"

airport = "EGLL"
airport.metar # => "EGLL 291750Z 22016KT 9999 SCT023 SCT032 18/13 Q1005"
```
The input ICAO code is **not case sensitive**, so the following should work as well:

```ruby
"kjfk".metar # => "KJFK 291751Z 24016KT 10SM FEW180 SCT250 32/21 A2968 RMK AO2 SLP049 T03170211 10322 20222 58008"

airport = "kjfk"
airport.metar # => "KJFK 291751Z 24016KT 10SM FEW180 SCT250 32/21 A2968 RMK AO2 SLP049 T03170211 10322 20222 58008"
```

## Technicalities

This library augments the default Ruby `String` class with a method named `.metar`. It returns a string, containing the latest Vatsim METAR. The data is obtained via `curl` from Vatsim's web API, hence the `curb` dependency.

## Contributing

Expand Down
8 changes: 3 additions & 5 deletions lib/vatsim_metar.rb
@@ -1,4 +1,5 @@
require "vatsim_metar/version"
require 'curb'

class String
def metar
Expand All @@ -7,11 +8,8 @@ def metar
end

module VatsimMetar
def self.metar(input)
"moo"
def self.metar(icao)
metar = Curl::Easy.perform("http://metar.vatsim.net/#{icao}").body_str
end

private


end
2 changes: 1 addition & 1 deletion lib/vatsim_metar/version.rb
@@ -1,3 +1,3 @@
module VatsimMetar
VERSION = "0.0.1.alpha"
VERSION = "0.0.1"
end
12 changes: 6 additions & 6 deletions spec/vatsim_metar_spec.rb
@@ -1,5 +1,4 @@
require 'spec_helper.rb'
require 'curb'

describe String do

Expand All @@ -12,11 +11,6 @@

describe ".metar" do

it "should return result" do
input = "egll"
input.metar.should eq("moo")
end

it "should use curl" do
icao = "egll"
metar = Curl::Easy.perform("http://metar.vatsim.net/#{icao}")
Expand All @@ -43,6 +37,12 @@
metar[0..3].should eq("KJFK")
end

it "should return valid result" do
input = "egll"
input.metar[0..3].should eq("EGLL")
"kjfk".metar[0..3].should eq("KJFK")
end

end

end
6 changes: 3 additions & 3 deletions vatsim_metar.gemspec
Expand Up @@ -4,9 +4,9 @@ require File.expand_path('../lib/vatsim_metar/version', __FILE__)
Gem::Specification.new do |gem|
gem.authors = ["Svilen Vassilev"]
gem.email = ["svilen@rubystudio.net"]
gem.description = %q{TODO: Write a gem description}
gem.summary = %q{TODO: Write a gem summary}
gem.homepage = ""
gem.description = %q{Pulls and returns as a sring the latest VATSIM metar for a particular station (ICAO code).}
gem.summary = %q{Pulls the latest VATSIM metar for particular station}
gem.homepage = "https://github.com/tarakanbg/vatsim_metar"

gem.files = `git ls-files`.split($\)
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
Expand Down

0 comments on commit 586da1f

Please sign in to comment.