class FccApi::CensusBlock

Public Class Methods

new() click to toggle source
# File lib/fcc_api.rb, line 10
def initialize
  @base_uri = "https://geo.fcc.gov/api/census/"
end

Public Instance Methods

get(lat, lon) click to toggle source
# File lib/fcc_api.rb, line 25
def get(lat, lon)
  request ={
    "format" => "json",
    "latitude" => lat,
    "longitude" => lon,
    "showall" => "false" 
  }
  make_http_call(request, "block/find")
          
end
get_all(lat, lon) click to toggle source
# File lib/fcc_api.rb, line 14
def get_all(lat, lon)
  request ={
    "format" => "json",
    "latitude" => lat,
    "longitude" => lon,
    "showall" => "true" 
  }
  make_http_call(request, "block/find")
          
end

Private Instance Methods

make_http_call(request, endpoint) click to toggle source
# File lib/fcc_api.rb, line 40
def make_http_call(request, endpoint)
  url = URI.parse( @base_uri  + endpoint + "?" + request.to_query )
  response = Net::HTTP.get( url  )
  return  JSON.parse(response)     
end