Skip to content

Instantly share code, notes, and snippets.

@jpettersson
Created April 3, 2013 04:09

Revisions

  1. jpettersson created this gist Apr 3, 2013.
    24 changes: 24 additions & 0 deletions example-usage.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,24 @@
    require 'airport_events'

    # Create a new Watcher instance and set up some event listeners.
    watcher = AirportEvents::Watcher.new

    watcher.on :connected do |ssid, date|
    puts "Connected to #{ssid} on #{date}"
    end

    watcher.on :disconnected do |date|
    puts "Disconnected on #{date}"
    end

    # Start the watcher, which runs in a separate Thread.
    watcher.start

    # Keep program alive until interrupted (For instance: CTRL + C).
    interrupted = false
    trap("INT") { interrupted = true }

    while true do
    exit if interrupted
    sleep 0.1
    end
    12 changes: 12 additions & 0 deletions example.json
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,12 @@
    [
    {
    "ssid": "orca",
    "connected_at": "2013-02-24T22:35:54+00:00",
    "disconnected_at": "2013-02-24T22:47:38-05:00"
    },
    {
    "ssid": "beluga",
    "connected_at": "2013-02-24T22:48:23-05:00",
    "disconnected_at": null
    }
    ]