Source

geomena / tools / geomena.rb

Full commit
require 'net/http'

# Usage:
# require 'geomena'
# Geomena::post(:mac => "1234560a0b0c", :latitude => 45.1, :longitude => -122.5)

class Geomena
  #GeomenaHost = "geomena.org"
  GeomenaHost = "localhost"

  def self.conn(&blk)
    Net::HTTP.start(GeomenaHost, 9393) do |http|
      yield http
    end
  end
  
  def self.post(params)
    data = params.map{|k,v| "#{k}=#{v}"}.join("&")
    conn do |http|
      http.post("/ap/#{params[:mac]}", data)
    end.body
  end
end